System.Web.UI.WebControls Namespace
Checks if the value of the associated input control matches the pattern of a regular expression.
The RegularExpressionValidator server control checks 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.
RegularExpressionValidator uses two key properties to perform its validation:
As with all validation controls, both server-side and client-side validation are performed unless the browser does not support client-side validation or client-side validation is explicitly disabled ( by setting the EnableClientScript property to false ).
The regular expression validation implementation is slightly different on the client than on the server. On the client, JScript regular expression syntax is used. On the server, Regex syntax is used. Since JScript regular expression syntax is a subset of Regex syntax, it is recommended that JScript regular expression syntax be used in order to yield the same results on both the client and the server.
NOTE: Validation succeeds if the input control is empty. To force the user to enter data into the input control, use a RequiredFieldValidator.
For examples illustrating use of this control, see the individual member types of this class. For syntax information, see RegularExpressionValidator in ASP.NET Syntax for Validation Controls.
BaseValidator Validating Against Patterns Regular Expressions Language Elements