Support us .Net Basics C# SQL ASP.NET ADO.NET MVC Slides C# Programs Subscribe Buy DVD

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.


If you like this website, please share with your friends on facebook and Google+ and recommend us on google using the g+1 button on the top right hand corner.