MVC Validator numberOfInvalids not working
- by user965445
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(); }
});
}
});