我遇到了 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" });
谢谢,
詹姆斯福特