This documentation is archived and is not being maintained.

Introduction to the RegularExpressionValidator Control

Use the RegularExpressionValidator control to test whether the data value in a TextBox or SelectionList control matches a regular expression. Set the RegularExpressionValidator control's ControlToValidate to the ID of the TextBox or SelectionList control to validate.

The RegularExpressionValidator control performs its validation by comparing the data value to the regular expression pattern specified in its ValidationExpression property. For information on using the Regular Expression Editor dialog box, which is associated with the ValidationExpression property, see Adding and Configuring a RegularExpressionValidator Control.

If the data value in the control specified by ControlToValidate does not match the regular expression in the ValidationExpression property, the RegularExpressionValidator control displays the string contained in its ErrorMessage property.

When you add a RegularExpressionValidator control to a container control or template:

  • The ErrorMessage property is set to RegularExpressionValidator.
  • The StyleReference property is set to error, which maps to a predefined style by default.

See Also

RegularExpressionValidator Control | RegularExpressionValidator Class | Adding and Configuring a RegularExpressionValidator Control | Introduction to the Validation Controls