I am using jQuery accordion to split my forms into several panels and jQquery validation to check the required fields. It works great to show errors in validated fields as long
The API has changed slightly, here is a working example based on the selected answer for anyone in the future. Note the ignore
which is needed to prevent the hidden fields in an accordion from being overlooked by the validator.
$('form').validate({
invalidHandler: function(event, validator) {
if (validator.numberOfInvalids() > 0) {
validator.showErrors();
// Open accordion tab with errors
var index = $(".has-error")
.closest(".ui-accordion-content")
.index(".ui-accordion-content");
$(".accordion").accordion("option", "active", index);
}
},
ignore: [],
});