1

We've been working with ASP.Net MVC2 based web app. We're using DataAnnotations for model validation and we've also implemented some of our own validation attributes. All is working good and the user gets the error summary (if any) after postback. Now, we plan to migrate to MVC3 in near future but meanwhile, we want to make the most out of jQuery & AJAX based validations.

Note that we've not been using any MS libraries for AJAX or validation available with MVC prjects. Our approach is to keep things as simple & clean as possible so we've been using pure jQuery based plugins. We want to enable client-side validation & remote validation using jQuery for which I believe jquery-plugin-validation is one of the best alternatives. It also supports remote validations.

Example: http://weblogs.asp.net/cibrax/archive/2008/08/01/combining-jquery-validation-with-asp-net-mvc.aspx


Automation:

APPROACH #1: Here it is mentioned that using "MicrosoftMvcJQueryValidation.js"will automate these validations - any comments?

APPROACH #: Here's another approach which seems to provide even more automation using jQuery DataAnnotations - any comments?

If I'm on the right track kindly based on your experience let me know which approach is better.


Further, is it true that this approach will help us migrate the validations easily as we migrate to MVC3.

Example: http://develoq.net/2011/asp-net-mvc-3-remote-validation-with-jquery/

Any better suggestions are welcome. Thank you.

PS: In any case we'll persist the model level validations.

2 Answers 2

2

In MVC3 you are able to rely solely on the jquery.validate.js library for validation (which is included by default), you do not need any ms specific libraries anymore (like MicrosoftMvcJQueryValidation.js or others, you CAN use them however).

Here is a simple blog post explaining how to use it, even going a step further and doing it unobtrusive:
http://geekswithblogs.net/stun/archive/2011/01/28/aspnet-mvc-3-client-side-validation-summary-with-jquery-validation-unobtrusive-javascript.aspx

On a second note:
The ASP.NET MVC 4 Beta was released a couple of days ago with a "go live" license, if you have not started to migrate I would recommend you to consider using MVC4 instead. It runs side by side with MVC 3, so you wont break anything by installing.

You can find the release notes here: http://www.asp.net/whitepapers/mvc4-release-notes

And download it here: http://www.asp.net/mvc/mvc4

Sign up to request clarification or add additional context in comments.

Comments

1

I strongly suggest that you wait until you migrate to a newer version. Anything you write in regards to validation will have to be rewritten for MVC3/4, so why waste the effort? I'd suggest that you invest your effort into upgrading and utilize the unobtrusive validation in MVC3 (or 4 as ntziolis suggests).

1 Comment

what if the migration is going to take more then a couple of months? I believe client site validation for static & dynamic rules is appealing to the end user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.