The typical way to validate fields in asp.net mvc is using Data Annonation validation attributes. There are several built in validators you can use, and you can write your own custom validators.
Here is a list of built in validators (taken from the post below):
Range – Enables you to validate whether the value of a property falls between a specified range of values.
ReqularExpression – Enables you to validate whether the value of a property matches a specified regular expression pattern.
Required – Enables you to mark a property as required.
StringLength – Enables you to specify a maximum length for a string property.
Validation – The base class for all validator attributes.
nissan
Participant
1065 Points
618 Posts
RequiredField validators
May 03, 2012 08:36 PM|LINK
I am new to MVC. What kind of required field validators do we have in MVC? for input boxes dropdowns?
CodeHobo
All-Star
18647 Points
2647 Posts
Re: RequiredField validators
May 03, 2012 09:43 PM|LINK
The typical way to validate fields in asp.net mvc is using Data Annonation validation attributes. There are several built in validators you can use, and you can write your own custom validators.
Here is a list of built in validators (taken from the post below):
Take a look at this aritcle on validation
http://www.asp.net/mvc/tutorials/older-versions/models-(data)/validation-with-the-data-annotation-validators-cs
Here's a post on building a custom validator:
http://msdn.microsoft.com/en-us/gg618485
Also take a look at this
http://msdn.microsoft.com/en-us/library/ee256141.aspx
Blog | Twitter : @Hattan