Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Form input validation options in ASP.NET MVC 1.0+

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)
like image 249
Richard Ev Avatar asked Dec 23 '22 09:12

Richard Ev


2 Answers

xVal should be good choice in your case.

like image 183
Dmytrii Nagirniak Avatar answered Jan 02 '23 02:01

Dmytrii Nagirniak


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

like image 33
Lasse Edsvik Avatar answered Jan 02 '23 02:01

Lasse Edsvik