If you store a reference to the validator, for example:
var validator = $("form").validate();
You can call .errors()
or .invalidElements()
at any time on it, for example:
var errors = validator.errors(); //get the error elements, the actual labels
var errors = validator.invalidElements(); //the invalid elements themselves
If you're not really after the errors and just want them to appear in once place, use the built-in errorLabelContainer
and wrapper
options, for example:
<ul id="errors"></ul>
And reference that:
$("form").validate({ errorLabelContainer: "#errors", wrapper: "li" });
And your errors would appear all in that list, which is also automatically shown/hidden if there are/aren't any errors.