Password Validation in Asp.net
Password Validation in Asp.net
Here is some validation for password manipulation.
It include validation with respect to character, numbers,
special characters, number of characters ,Upper case and lower case Characters.
.Aspx Page with textbox and validators.
<div>
<table>
<tr>
<td>
Password validation include
<span style=" color:royalblue"> 8 Characters, 1 Alphabet and 1 Number</span>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtpass1" runat="server"></asp:TextBox><br />
<asp:RegularExpressionValidator ID="Regex1" runat="server" ControlToValidate="txtpass1"
ValidationExpression="^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$" ErrorMessage=" Minimum 8 characters atleast 1 Alphabet and 1
Number" ForeColor="Red" />
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td> Password validation include <span style=" color:royalblue"> 8
Characters, 1 Alphabet ,1 Number and 1 Special Character</span></td>
</tr>
<tr>
<td><asp:TextBox ID="txtpass2" runat="server"></asp:TextBox><br />
<asp:RegularExpressionValidator ID="Regex2" runat="server" ControlToValidate="txtpass2"
ValidationExpression="^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,}$"
ErrorMessage="Minimum 8 characters atleast 1 Alphabet, 1 Number
and 1 Special Character" ForeColor="Red" /></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>Password validation include <span style=" color:royalblue">8 Characters, 1 UpperCase Alphabet, 1 LowerCase Alphabet
and 1 Number </span></td>
</tr>
<tr>
<td><asp:TextBox ID="txtpass3" runat="server"></asp:TextBox><br />
<asp:RegularExpressionValidator ID="Regex3" runat="server" ControlToValidate="txtpass3"
ValidationExpression="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$"
ErrorMessage="Minimum 8 characters atleast 1 UpperCase Alphabet,
1 LowerCase Alphabet and 1 Number" ForeColor="Red" /></td>
</tr>
<tr>
<td>Password validation include <span style=" color:royalblue"> 8 Characters, 1 UpperCase Alphabet, 1 LowerCase Alphabet,
1 Number and 1 Special Character</span></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><asp:TextBox ID="txtpass4" runat="server"></asp:TextBox><br />
<asp:RegularExpressionValidator ID="Regex4" runat="server" ControlToValidate="txtpass4"
ValidationExpression="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,}"
ErrorMessage=" Minimum 8 characters atleast 1 UpperCase Alphabet,
1 LowerCase Alphabet, 1 Number and 1 Special Character" ForeColor="Red" /></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>Password validation include<span style=" color:royalblue"> Minimum 8 and Maximum 10 characters atleast 1 UpperCase
Alphabet, 1 LowerCase Alphabet, 1 Number and 1 Special Character</span></td>
</tr>
<tr>
<td><asp:TextBox ID="txtpass5" runat="server"></asp:TextBox><br />
<asp:RegularExpressionValidator ID="Regex5" runat="server" ControlToValidate="txtpass5"
ValidationExpression="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,10}"
ErrorMessage="Minimum 8 and Maximum 10 characters atleast 1
UpperCase Alphabet, 1 LowerCase Alphabet, 1 Number and 1 Special
Character"
ForeColor="Red" /></td>
</tr>
</table></div>
Comments
Post a Comment