I\'m using jquery for validation in my MVC2 web app (as described here) and I\'d like to wire up some callbacks that the jquery validation plugin supports, like invalidHandler,
From Herikstad.net:
If you have a problem where you need to add the option
invalidHandler
to your jqueryValidate (jQuery Validation Plugin) after it has been initialized, this is how it can be done:$(document).ready(function(){ $("#contactForm").bind('invalid-form.validate', function(form, validator) { alert('validation failed!'); } ); });
Regularly you would add this on initialization:
$(document).ready(function(){ $('#contactForm').validate({ invalidHandler: function(form, validator) { alert('validation failed!'); }, rules: {} }); });
Note: invalidHandler will be called when validation of form fails on submit (e.g. values for a field is missing or such).
This might work for other options of the jqueryValidate plugin, but I'm not sure which property to use. I found the property to bind to in the jquery.validate.js file, you might want to look there.