How many types of validation controls are provided by ASP.NET?
There
are mainly six types of validation controls provided by ASP.NET which
are as follows:
- Required Field Validator
This validator ensures that the user does not skip a form entry field.
- Regular Expression Validator
This validator is used to match the user's entry against an expression defined by a regular expression.
Example of some commonly used regular expressions:
URL: (http(s)?://)?([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
Email: \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
US Zip Code: ^(\d{5})(-\d{4})?$
Reference: http://msdn.microsoft.com/en-us/library/ms972966.aspx
- Range Validator
This validator is used to compare data based on a range provided.
Once can change the Type to match the requirements.
- Compare Validator
This validator is used to compare data entered by user in two different fields, for e.g. password
One can change the Type or the Operator to match the requirements. - Custom Validator
Custom validator is used in cases where custom code is needed to validate an user's entry.
The above example displays as to how to do a server side validation, below is an example as to how to do a client side validation.
Comments
Post a Comment