HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
color: #FF9900;
}
.style3
{
color: Teal;
}
.requiredFieldValidateStyle
{
color: Red;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<span class="style3"><b style="font-weight: bold; font-size: 14">Email Validation example</b></span>
<table class="style1">
<tr>
<td width="150">
Enter your your email
</td>
<td width="5px">
:
</td>
<td>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Please Enter you valid email"
ControlToValidate="txtEmail" CssClass="requiredFieldValidateStyle" ForeColor="Red"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">
</asp:RegularExpressionValidator>
</td>
</tr>
</table>
<span class="style3"><b style="font-weight: bold; font-size: 14">Maximum character length
Validation(allowed only 10 character) </b></span>
<table class="style1">
<tr>
<td width="150">
UserName
</td>
<td width="5px">
:
</td>
<td>
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator Display="Dynamic" ControlToValidate="txtUserName"
ID="RegularExpressionValidator1" ValidationExpression="^[\s\S]{0,8}$" runat="server"
ErrorMessage="Maximum 8 characters allowed." CssClass="requiredFieldValidateStyle"></asp:RegularExpressionValidator>
</td>
</tr>
</table>
<span class="style3"><b style="font-weight: bold; font-size: 14">Combination of UpperCase
LowerCase, Number and Special Character </b></span>
<table class="style1">
<tr>
<td width="150" valign="top">
Enter Your Password
</td>
<td width="5px" valign="top">
:
</td>
<td>
<asp:TextBox ID="txtCombinatio" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegCombination" runat="server" ControlToValidate="txtCombinatio"
ValidationExpression="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{6,}"
ErrorMessage=" Minimum 6 characters at least 1 UpperCase ,<br> 1 LowerCase 1 Number and 1 Special Character"
ForeColor="Red" />
</td>
</tr>
</table>
<span class="style3"><b style="font-weight: bold; font-size: 14">Combination of UpperCase
,LowerCase,<br />
with Maximum and Minimum character <br />
Number with Special Character </b></span>
<table class="style1">
<tr>
<td width="150">
Enter Your Password
</td>
<td width="5px">
:
</td>
<td>
<asp:TextBox ID="txt2npassword" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="Reg2nPassword" runat="server" ControlToValidate="txt2npassword"
ValidationExpression="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{6,12}"
ErrorMessage=" Minimum 6 and Maximum 12 characters atleast<br> 1 UpperCase 1 LowerCase, 1 Number and 1 Special Character"
ForeColor="Red" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>