Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery validation without requiring MS scripts in asp.net mvc2 project

Is it possible to use the new client side validation features of asp.net MVC 2 without having to use the MS scripts (MicrosoftAjax.js, MicrosoftMvcAjax.js, MicrosoftMvcValidation.js)?

I use JQuery throughout my application; JQuery has a great plugin for validation and I don't really want to force my users to load MS scripts just for validation.

Is this possible? If so, any suggestions for how to accomplish it are appreciated.

like image 483
Jim Geurts Avatar asked Mar 21 '10 00:03

Jim Geurts


1 Answers

Here's what you need on the client:

<script src="/Scripts/jquery-1.4.2.min.js" type="text/javascript" />
<script src="/Scripts/jquery.validate.min.js" type="text/javascript" />
<script src="/Scripts/MicrosoftMvcJQueryValidation.js" type="text/javascript" />

So no, you don't need the files in your question...and you're definitely taking the right route keeping it from being bloated. Just by using the scripts listed above instead of the default ones, validation should be all setup. (MicrosoftMvcJQueryValidation.js hooks up to the JSON MVC2 dumps in the page)

Phil Haack has a good post explaining it more in-depth here

like image 144
Nick Craver Avatar answered Nov 17 '22 16:11

Nick Craver