Last active
April 5, 2021 18:56
-
-
Save MubinSayed/1eb5fb1b4b51ade87f25953dd0b55359 to your computer and use it in GitHub Desktop.
Get Error List in jQuery .validate plugin Invalid Handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In the invalidHandler, you are passed two arguments, a jQuery.Event and the validator object. | |
// You don't need to call validate within your invalidHandler to get the validate object. | |
// Further, the validator object has a properties called errorList and errorMap, which contain the information you are looking for. | |
invalidHandler: function(e,validator) { | |
//validator.errorList contains an array of objects, where each object has properties "element" and "message". element is the actual HTML Input. | |
for (var i=0;i<validator.errorList.length;i++){ | |
console.log(validator.errorList[i]); | |
} | |
//validator.errorMap is an object mapping input names -> error messages | |
for (var i in validator.errorMap) { | |
console.log(i, ":", validator.errorMap[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment