Which scripts do I need for MVC3 validation?
I have been using the following:
<script src="//ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>
<script src="//ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js" type="text/javascript"></scr开发者_JAVA百科ipt>
<script type="text/javascript">
window.jQuery || document.write('<script src="/Scripts/jquery/jquery-1.6.1.min.js"><\/script>')
window.jQuery || document.write('<script src="/Scripts/jquery/jquery.unobtrusive-ajax.min.js"><\/script>')
window.jQuery || document.write('<script src="/Scripts/jquery/validate.validate.min.jss"><\/script>')
</script>
I know things have changed with MVC3. Can someone please confirm that these are the correct scripts I should be using if I want to do validation on my MVC3 page. Also where's a good source for the latest versions? I can't see any mention of jquery.validate.min.js on the google API site.
Would it be good practice to try and get all these from the Microsoft CDN, should I get jquery from google and the others from Microsoft?
The scripts we use for validation in our MVC 3 project are:
- jquery-1.6.1.min.js
- jquery.unobtrusive-ajax.min.js
- jquery.validate.min.js
- jquery.validate.unobtrusive.min.js
They are basically the same files as the ones mentioned by you. Here's a tutorial on handling unobtrusive client validation on MVC 3 - http://lucbei.wordpress.com/2010/11/18/mvc3-unobtrusive-javascript-validation-via-html5-in-razor-rocks/
You should use a CDN for all of these scripts as this can improve the times in page loading. From my perspective I think you can use either of the Google API site or the Microsoft Ajax CDN for the jquery script.
精彩评论