Ability to Run a Invalid Call Back on a Rule
I needed to run a call back if a specific field was invalid. Maybe I am missing something but it seems that I could only run the callback on all the fields , iterate through them and check if it was the field that I needed the callback for (modal pop).
I attached an a very dumbed down version of it via JS Fiddle to show the round about way I achieved this but I was wondering if there was either a better way to do this via rules or if this is a feature that could be added
http://jsfiddle.net/c61aj5kv/1/
onInvalid is called for each invalid field with the this context set to the field. You don't have to iterate through the errors to figure out which error occurred.
Checking against this is the easiest way to figure out which field was invalid.
You can do something like:
onInvalid: function() {
// some special field
if($(this).hasClass('special') {
$('.some.modal').modal('show');
}
}
Brilliant, thank you!