我正在尝试使用jquery验证来在表单有效时取消隐藏paypal按钮。我正在使用valid()
方法,如下所示。问题是,只要在任何表单元素中按下一个键,就会显示所有错误。如何在不解决所有错误的情况下检查它是否有效?
$('#jValidate').validate({
rules:{
username:{
required:true,
minlength:6
},
email:{
required:true,
email:true
},
password:{
required:true,
minlength:8
},
confirm:{
required:true,
equalTo:"#password"
}
},
messages:{
username:{
required:"Username is required",
minLength:"Username must be at least 6 characters"
},
password:{
required:"Password is required",
minLength:"Password must be at least 8 characters"
},
confirm:{
required:"You must confirm your password",
equalTo:"Password Confirmation does not match"
}
}
});
$('#jValidate .form-control').keyup(function(){
if($('#jValidate').valid()){
$('#signup').show();
$('#disabled').hide();
}
});
答案 0 :(得分:0)
var validator = $('#jValidate').validate({...rules, options});
validator.checkForm() // true if valid, false if not.