jquery - Trigger an event if there are validation errors? -


i need add handle circumstance form validation fails.

i've read this, explains have add handler follows:

$('form').bind('invalid-form.validate', function () {   console.log('form invalid!'); }); 

but event fires when try submit form.

i need handle event that's fired time form post-validated (i.e. element loses focus etc.).

what i'm trying achieve is, have large form (~50 fields), , it's splitted in bootstrap tabs.
want, when there new validation failure or success, set or clear error class in tab title of tab contains invalid/valid elements. p.s. question not on how set classes in tabs. want know event(s) handle in order notified upon each validation state change in entire form.

i need add handler circumstance form validation fails.

$('input, textarea, select').on('focusout keyup', function() {    if ($('form').valid()) {        //    } }); 

i want, when there validation error, set error class in tab title contains invalid elements.

well, that's bit different asked about. (ignore first half of answer.)

use highlight , unhighlight options along jquery dom traversal set , unset class in dom wish. highlight fires when invalid , unhighlight fires when becomes valid. see this answer example.

use the .setdefaults() method set these options since you're using unobtrusive-validation plugin , have no direct access .validate() method.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -