jQuery Validation - get list of erroneous fields in invalidHandler

Viewed 29511

I'm using jQuery Validation on a page. During the call to the invalidHandler I would like to be able to access a list of all the form elements that failed validation.

This function is being passed as one of the options to the jQuery.validate() method...

invalidHandler: function (form) {
    var validator = $("#AddEditFinancialInstitutionForm").validate();
    validator.showErrors();
    console.log(validator);
}

I'm trying to find this information somewhere in the resulting validator object, but I can't seem to find it. Is there another way I can access this information?

Thanks

3 Answers

use this for getting errored field's whole element and it's attributes.

  var formerrorList = $("#FORM_ID_HERE").data("validator").errorList;
        $.each(formerrorList, function (key, value) {
            console.log(formerrorList[key].element.id);
        });
Related