Regular Expression Validator Control in asp.net
For Example: Write a program to demonstrate the use of regular expression validator control
<html>
<head runat="server">
<title>Aryan Computers( Range Validator control) </title>
</head>
<body>
<form id="form1" runat="server">
<center>
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="XX-Large"
ForeColor="#CC0066" Text="Aryan Computers, Barshi"></asp:Label>
<br /></center><p>
<asp:Label ID="Label2" runat="server" Font-Bold="True"
Text="First Name: "></asp:Label>
<asp:TextBox ID="TextBox4" runat="server" style="margin-left: 50px"
Width="233px"></asp:TextBox>
</p>
<asp:Label ID="Label3" runat="server" Text="Last Name:" Font-Bold="True"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Height="25px"
style="margin-left: 68px" Width="240px"></asp:TextBox>
<p>
<asp:Label ID="Label4" runat="server" Text="E-Mail : " Font-Bold="True"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"
style="margin-left: 80px; margin-bottom: 0px" Width="360px" Height="26px"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w{2,4}([-.]\w{2,4})*([,;]\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w{2,4}([-.]\w{2,4})*)*"
ControlToValidate="TextBox2"
runat="server"
ErrorMessage="Enter correct Email format"></asp:RegularExpressionValidator>
<asp:Label ID="Label5" runat="server" Text="Mobile Number:" Font-Bold="True"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server" style="margin-left: 33px"
Width="212px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Font-Bold="True" Height="31px"
Text="Submit" Width="148px" style="margin-left: 170px" />
</form>
</body>
</html>
Output:

Comments
Post a Comment