How to: Add and Configure a RegularExpressionValidator Control
Use thecontrol to match the value in another control against a predefined pattern.
If the user leaves the targeted control blank, the control passes validation. To force the user to enter a value, add acontrol in addition to the RegularExpressionValidator.
To validate the entry in a control by matching a pattern
Add a RegularExpressionValidator control to the form that contains the target control.
Set theproperty to the ID of the control that you want to validate.
Type a regular expression into theproperty in the Properties window.
Alternatively, click the ellipsis button () next to the ValidationExpression property to display the Regular Expression Editor dialog box, and then select a predefined regular expression.
Set theproperty to the text to display in the RegularExpressionValidator control if the targeted control fails validation.
If you enter a string into theproperty, the RegularExpressionValidator control displays that text when an error occurs. If the Text property is left empty, the RegularExpressionValidator control displays the string defined in the ErrorMessage property.