Question

A number of questions have been asked on this topic before, but since ASP.NET MVC is moving quite fast I wanted to re-ask the question:

What would you recommend for providing form input validation in ASP.NET MVC?

Requirements:

  • Server-side checking
  • Client-side (JavaScript) checking
  • Should cover the basics such as mandatory fields, numeric range validation, regex validation

(So basically all (or most) of the stuff that the ASP.NET WebForms validation controls do)

Current options seem to be:

  1. Validator Toolkit on CodePlex
  2. Jumping to ASP.NET MVC 2 Preview 1 (Our application is for internal use and go-live is in 6 months, so we might be comfortable using the preview)
Was it helpful?

Solution

I would use DataAnnotations, is going to be a part of MVC but can be compiled and used in 1.0.

http://www.asp.net/learn/mvc/tutorial-39-cs.aspx

/M

OTHER TIPS

xVal should be good choice in your case.

FluentValidation also has an MVC component, however it doesn't do the client side of things. Ideally this could be integrated with xVal.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top