似乎无法让它发挥作用。尝试确认电子邮件引导验证程序。原始电子邮件验证工作但不是第二个。不确定我错过了什么。
<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 :(得分:1)
您可以使用equalTo方法:
$('#myform').validate({
rules: {
email: 'required',
emailConfirm: {
equalTo: '#email'
}
}
});