Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

RegularExpressionValidator

0.00/5 (No votes)
4 Jul 2008 1  
The RegularExpressionValidator control confirms that the entry matches a pattern defined by a regular expression. This type of validation allows you

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

The RegularExpressionValidator control confirms that the entry matches a pattern defined by a regular expression. This type of validation allows you to check for predictable sequences of characters, such as those in social security numbers, e-mail addresses, telephone numbers, postal codes, and so on.  Some common regular expressions are:

  • US Zip Codes:  \d{5}
  • US Phone Numbers:  \d{3}-\d{3}-\d{4}
  • Email address:  \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

RegularExpressionValidator uses two key properties to perform its validation: ControlToValidate contains the value to validate, and ValidationExpression contains the regular expression to match.

Whitepapers/Blogs

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here