Support us .Net Basics C# SQL ASP.NET Aarvi MVC Slides C# Programs Subscribe Download

RegularExpressionValidator control in - Part 47

Suggested Videos
Part 44 - RequiredField
Part 45 - Rangevalidator
Part 46 - CompareValidator

This is a very powerful validation control. This control is used to check if the value of an associated input control matches the pattern specified by a regular expression. The only property that is specific to the RegularExpressionValidator is ValidationExpression.

RegularExpressionValidator control in

This example, checks if the input mataches the pattern of an email address
<asp:TextBox ID="txtEmail" runat="server" Width="150px">
<asp:RegularExpressionValidator ID="RegularExpressionValidatorEmail" runat="server" 
ControlToValidate="txtEmail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ErrorMessage="Invalid Email" ForeColor="Red"></asp:RegularExpressionValidator>

By default client side validation is turned on. To disable client side validation set EnableClientScript o false. This property is supported by all validation controls.

To disable validation control set Enabled propety to false.

1 comment:

  1. Hi Venkat,
    How to Validate the Controls(TextBox) inside a DataBound Control such as GridView.
    Please give us the idea as soon as posiible.


It would be great if you can help share these free resources