The RegularExpressionValidator control is used to determine whether the value of an input control 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.
Note: |
|---|
If the input control is empty, no validation functions are called and validation succeeds. Use a
RequiredFieldValidator control to prevent the user from skipping an input control.
|
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 (the EnableClientScript()()() property is set to false).
Use the ValidationExpression()()() property to specify the regular expression used to validate an input control. The regular expression validation syntax 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. Because JScript regular expression syntax is a subset of Regex syntax, it is recommended that you use JScript regular expression syntax in order to yield the same results on both the client and the server.
For additional information on creating and formatting regular expressions, see .NET Framework Regular Expressions.
For detailed information on the RegularExpressionValidator control, see the RegularExpressionValidator class.