2017-06-07 9 views
0

がこの仕事を得るように見えることはできません。確認メールのブートストラップ・バリデータをやろうと。元の電子メールのバリデータの作品ではなく、第二。私は何が欠けているか分からない。同じメールブートストラップ検証

<div class="form-group"> 
     <div class="col-md-11"> 
     <label for="inputEmail" class="sr-only">Enter Email</label> 
     <input type="email" class="form-control" placeholder="Enter Email" id="email" name="email" size="35" required/> 
     <div class="help-block with-errors"></div> 
     <span class="glyphicon form-control-feedback" id="email1"></span> 
    </div> 
    </div> 
    <div class="form-group"> 
     <div class="col-md-11"> 
      <input type="email" class="form-control" name="emailConfirmed" placeholder="Confirm Email" id="emailConfirmed" size="35" /> 
    </div> 
</div> 

$('#form').validate({ 
    fields: { 
     email: { 
      minlength: 3, 
      required: true, 
      validators: { 
       notEmpty: { 
        message: 'The confirm email is required and cannot be empty' 
       }, 
       identical: { 
        field: 'emailConfirmed', 
        message: 'The email and its confirm are not the same' 
       } 
      } 
     }, 
     emailConfirmed: { 
      validators: { 
       notEmpty: { 
        message: 'The confirm email is required and cannot be empty' 
       }, 
       identical: { 
        field: 'email', 
        message: 'The email and its confirm are not the same' 
       } 
      } 
     } 
    } 
}); 
+0

あなたは、検証のためにどのようなライブラリを使用しているの? –

+0

可能性のある重複した[jQueryを使ってマッチ2つのフィールドは、プラグインを有効化](https://stackoverflow.com/questions/5147438/match-two-fields-with-jquery-validate-plugin) – Jeevan

答えて

2

あなたはequalTo方法使用できます

$('#myform').validate({ 
    rules: { 
     email: 'required', 
     emailConfirm: { 
      equalTo: '#email' 
     } 
    } 
}); 
+0

うん、これは感謝を働きました! – Keith

関連する問題