views:

932

answers:

1

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.

+6  A: 

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

Nick Craver
Perfect, thanks!
Jim Geurts
To compliment this answer, there is a great walkthrough of how to setup jquery validation with mvc at http://geekswithblogs.net/stun/archive/2010/02/27/asp.net-mvc-client-side-validation-summary-with-jquery-validation-plugin.aspx
Jim Geurts