Validating ASP.NET MVC 3 and jQuery

What is the best way to do validation in MVC 3? Here are the requirements:

  • It works on the client and server side.
  • Provides as much code as possible between the client and server (the model property attribute seems perfect)
  • Works on asynchronous request
  • Display errors, verification messages, and success messages from the server.
  • Unobtrusive javascript, as minimal as possible
  • Dynamically added HTML should still check the same.

My task this weekend is to build a reliable solution for this, believing that I will ask here first before reinventing or re-opening the wheel with sweat and blood tears.

+4
source share
1 answer

I would check out Brad Wilson's blog . It covers the use of unobtrusive validation in MVC3, similar to what you are looking for.

Adding More Information for OP Comment

Regarding server-side validation (spot-checking), check @jfar response for a similar question that I posted regarding user-side validation - it suggests you ask a question about your design if you rely heavily on user-specific validation. In my case, I ended up working with Ajax to handle my own validation, or allowed postback to do the validation.

+1
source

All Articles