Javatpoint Logo
Javatpoint Logo

ASP.NET RegularExpressionValidator Control

This validator is used to validate the value of an input control against the pattern defined by a regular expression.

It allows us to check and validate predictable sequences of characters like: e-mail address, telephone number etc.

The ValidationExpression property is used to specify the regular expression, this expression is used to validate input control.

RegularExpression Properties

Property Description
AccessKey It is used to set keyboard shortcut for the control.
BackColor It is used to set background color of the control.
BorderColor It is used to set border color of the control.
Font It is used to set font for the control text.
ForeColor It is used to set color of the control text.
Text It is used to set text to be shown for the control.
ToolTip It displays the text when mouse is over the control.
Visible To set visibility of control on the form.
Height It is used to set height of the control.
Width It is used to set width of the control.
ErrorMessage It is used to set error message that display when validation fails.
ControlToValidate It takes ID of control to validate.
ValidationExpression It is used to set regular expression to determine validity.


Here, in the following example, we are explaining how to use RegularExpressionValidator control to validate the user input against the given pattern.

// RegularExpressionDemo.aspx


It produces the following output when view in the browser.

ASP Regular 1

It will validate email format as we specified in regular expression. If validation fails, it throws an error message.

ASP Regular 2

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA