My Profile

Thursday, February 10, 2011

ASP.Net - RegularExpressionValidator


 
1.    RegualrExpressionValidation Control:
·       With this control, we can perform validations by providing an expression, which is nothing but some characters indicating one format or a validation.
·       Many validations like checking for length of entered value, accepting only integers, alphabets or combination can be performed using this validator.
·       It is a language feature to support expression based validation and also some calculations.
·       .Net provides “System.Text.RegularExpressions” namespace which contains classes to perform expression based validations.
·       In ASP.Net RegularExpressionValidator also provides the same functionality. The advantage of using these expressions is to get more accuracy in validation as well as without writing code.

Some characters in regular expressions:
^        Beginning
$       Ending
{}       Length
\d      Digits
\w     word
[]       Range
And many more…

Examples:
  • [A-Za-z0-9]{6} : 6 alphabets (caps and small)/numbers/combination
  • [A-Za-z]{4}\d{2}  : first 4 characters alphabets and next 2 characters digits.
  • \d{10,12}  : digits, minimum 10 and maximum 12.


---------------------------------------------------------- 
** If you like this post please like our page in 
facebook " Dot Net Support"

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More