Click here to Skip to main content
15,908,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody,

I am developing a new website using asp.net .

in change password screen , the new password field must contain atleast one numeric,alphabet(one caps,one small),special character. I need regex string for it will you please anyone help me to solve this.

Regards ,
Velsamy
Posted

Try this....


<asp:textbox id="txtPassword" runat="server" />

<asp:regularexpressionvalidator id="Regex4" runat="server" controltovalidate="txtPassword"
ValidationExpression="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,}"
ErrorMessage="Password must contain: Minimum 8 characters atleast 1 UpperCase Alphabet, 1 LowerCase Alphabet, 1 Number and 1 Special Character" ForeColor="Red"/>
 
Share this answer
 
v3
Comments
avelsamy 10-Jul-14 5:22am    
yeah i have used the same expression , which is sent by code project frnd

Thank u
XML
<asp:TextBox ID="txtpass" runat="server"></asp:TextBox><br />
<asp:RegularExpressionValidator ID="Regex5" runat="server" ControlToValidate="txtpass"
    ValidationExpression="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,10}"
    ErrorMessage="Password must contain: Minimum 8 and Maximum 10 characters atleast 1 UpperCase Alphabet, 1 LowerCase Alphabet, 1 Number and 1 Special Character"
ForeColor="Red" />




for example:PaSs@123
 
Share this answer
 
Comments
avelsamy 10-Jul-14 5:18am    
Mr. chauhanvatsal,
Its working fine,
could u explain how its working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900