I need to add an handle to any circumstance where a form validation fails.
I've read this, that explains that I have to add a handler as follows:
$('form').bind('invalid-form.validate', function () {
console.log('form is invalid!');
});
But this event only fires when I try to submit the form.
I need to handle an event that's fired ANY time the form is post-validated (i.e. element loses focus etc.).
What I'm trying to achieve is, I have a large form (~50 fields), and it's splitted in Bootstrap tabs.
I want, that when there is any new validation failure or success, set or clear an error class in the tab title of the tab that contains the invalid/valid elements. P.S. my question is not on how to set those classes in the tabs. I only want to know what event(s) to handle in order to be notified upon each validation state change in the entire form.
focusout
,blur
,keyup
, etc to every input element and use the.valid()
method to test the form. – Condonationonvalidated
provided by the unobtrusive validation plugin? – Beebeunobtrusive
plugin at all. However within all the thousands of jQuery Validate questions I've seen, I've never seen any custom events described. – Condonationvalidate
at all. It sets it all up for you. Anyway I've updated my question with the purpose of my requirement. – BeebesetDefaults()
to get around the inability to call.validate()
. – Condonation