Friday, March 9, 2012

ASP.NET MVC 3: Configuring unobtrusive validation

ASP.NET MVC 3 ofeers client side validation through the unobtrusive javascript and jQuery validation plugins. Most of the time the default behavior is fine, but what if you want to tweak the validation configuration?

Only validate the form fields when the form is submitted:

As you can see, it’s possible to change some settings through the validator settings object. By setting the onkeyup and onfocusout properties to false, the validation on blur and key up will be disabled.