In a previous MVC 2.0 application, I included (in my Site.Master) a reference to the CDN file of jquery.validate.min.js for all my client-side validation.
I’m now creating an MVC 3.0 project and I’m a bit confused with the amount of articles written about “how to use client-side validation using MicrosoftMvcValidation.js”.
In most (if not all) articles, when I see a reference to MicrosoftMvcValidation.js I also see a reference to jquery.validate.js which is kind of confusing (considering, in the past, I’ve only used bassistance’s file).
So my questions are:
- What is the difference between these two files?
- Are there any known issues/benefits in using one over the other?
- Inside the “
Scripts” folder, by default, it looks like both files
are there but why? Do they give us the choice or do they work hand in
hand?
Any help shedding some light on this would be great!
Thanks in advance!
MVC3 supports two modes of client-side validation:
Classical validation using MicrosoftMvcValidation.js
To enable this, call
Html.EnableClientValidation()beforeHtml.BeginForm().Unobtrusive validation using jquery.validate.js and jquery.validate.unobtrusive.js (new to MVC3)
To enable this, add the following settinsg to Web.config: