我遇到了jquery验证插件和invalidHandler的问题。处理程序被调用两次?第一次是本地验证的字段,第二次是我的所有远程ajax验证都已完成。
我猜这是因为本地验证的字段在远程字段之前返回false。有可能解决这个问题吗?
$("#create users").validate(
{
debug: true,
errorElement: "div",
errorPlacement: function(error, element) {
error.appendTo(element.closest('div').next().next());
},
invalidHandler: function(form, validator) { // Called twice
$("#validation-dialog").dialog('close');
},
submitHandler: function(form) {
$("#validation-dialog").dialog('close');
$("#create-accounts-dialog").dialog({
resizable: false,
draggable: false,
height: 200,
width: 400,
modal: true,
buttons: {
GetString("Cancel"): function() {
$(this).dialog("close");
},
GetString("Ok"): function() {
$(".modal-load").show();
$(".ui-icon-info").hide();
$(".modal-text").hide();
$(".ui-dialog-buttonpane").hide();
form.submit();
}
}
});
}
});
$.validator.addMethod("required", $.validator.methods.required, GetString("validationRequired"));
$.validator.addMethod("email", $.validator.methods.email, GetString("validationRequired"));
$.validator.addMethod("remote", $.validator.methods.remote,GetString("validationDouble"));
$.validator.addClassRules("uEmail", { required: true, email: true, remote: "/CheckDouble/@Model.Id" });
谢谢,
詹姆斯·福特