MVC Validator numberOfInvalids not working
Posted
by
user965445
on Stack Overflow
See other posts from Stack Overflow
or by user965445
Published on 2012-10-04T15:20:29Z
Indexed on
2012/10/04
15:37 UTC
Read the original article
Hit count: 139
I dynamically add some elements to a form so I know I need to re-parse the form. Even if I have old invalid elements they don't get identified in numberOfInvalids It always comes back = 0 even though the invalid fields are highlighted on the page.
var form = $("#form");
//Form Savingform.submit(function (e) {
e.preventDefault();
form.removeData("validator");
form.removeData("unobtrusiveValidation");
$.validator.unobtrusive.parse(form);
var val = form.validate();
if (val.numberOfInvalids() == 0) {
$.blockUI({ fadeIn: 1000 });
AjaxRequest({
data: $(this).serializeArray(),
success: function (data, status, xhr) { alert('sucess save or submit, use "'); },
complete: function () { $.unblockUI(); }
});
}
});
© Stack Overflow or respective owner