我正在使用jquery.validate()验证我的注册表单,一切运行正常,但我的表单email
字段存在一个问题,因为我添加了一个custome方法来检查{{1数据库中是否存在。
这是我的工具:
email
问题:每当我在 $(document).ready(function(){
var _user = new User();
$.validator.addMethod(
"isEmailExist",
function(value, element) {
return _user.isEmailNotExist(value);
},
"Username is Already Taken"
);
$("#registerForm").validate({
rules: {
firstname: {
required : true,
maxlength: 30
},
lastname: {
required : true,
maxlength: 30
},
password: {
required: true,
minlength: 5,
maxlength: 30
}
email: {
required: true,
email: true,
maxlength: 30,
isEmailExist : true
}
},
messages: {
firstname: "Please enter your firstname",
lastname: "Please enter your lastname",
password: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long"
},
email: {
email : "Please enter a valid email address",
isEmailExist : "This email is already existed"
}
}
});
});
字段中输入字符时,email
正在运行,因此验证文本框需要一段时间。
我想要的:仅在我将鼠标移出时验证isEmailNotExist()
字段。
任何帮助将不胜感激。它是一个很好的解决方案来验证鼠标出来?感谢。