Skip to content

Instantly share code, notes, and snippets.

@giiska
Created July 24, 2014 08:42
Show Gist options
  • Save giiska/d9c2123a7c6e83ab46e0 to your computer and use it in GitHub Desktop.
Save giiska/d9c2123a7c6e83ab46e0 to your computer and use it in GitHub Desktop.
jquery.validate: accordion show when form in it is invalid by config `invalidHandler`
$form.validate({
ignore: '.ignore',
rules: rules,
messages: messages,
invalidHandler: function(event, validator) {
// console.log(event, validator);
var errorEl = validator.findLastActive() || validator.errorList.length && validator.errorList[0].element;
if(errorEl)
$(errorEl).closest('.accordion-body').collapse('show');
},
submitHandler: function(form) {
_submitForm(form);
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment