Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

Am using JavaScript validation for password.
My Requirement is to have
1.At least and must contain one numeric, one alphabetic, and one special characters.

The patterns that I have tried are as follows:

1.(?!^[0-9]*$)(?!^[a-zA-Z]*$)(?!^[!@#$%^&*+-]*$)^([a-zA-Z0-9!@#$%^&*+-]{3,20})$
2.((?=.*[a-z])(?=.*d)(?=.*[@#$%])(?=.*[A-Z]).{3,20})
3.^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[!@#$%^&*+-])(.{3,})$
4.^((?=.*[a-zA-Z])(?=.*\d).{3,20}$).*$
5.(?=^.{8,}$)(?=.*\d)(?=.*[!@#$%^&*]+)(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$
6.^(?=^.{3,}$)(?=.*\d)(?=.*[!@#$%^&*]+)(?=.*[A-Za-z]).*$


None of the above working for me.

Can any buddy suggest specific one which will work around.


Thanks & Regards
Yogesh
Posted
Updated 9-Oct-21 3:12am
Comments
Anuja Pawar Indore 6-Jan-14 4:19am    
Refer this
http://stackoverflow.com/questions/7026283/regex-to-accept-atleast-one-alphabet-one-numeric-char-and-one-special-character
Anuja Pawar Indore 6-Jan-14 4:25am    
^([a-zA-Z+]+[0-9+]+[&@!#+]+)$
try this also, i have added symbols that was required as per Password policy.

Try this:
^(?=.*[0-9].*)(?=.*[a-zA-Z])(?!.*\s)[0-9a-zA-Z*$-+?_&=!%{}/'.]*$
 
Share this answer
 
Comments
Member 10434230 6-Jan-14 4:24am    
you can easily verify RegExp at : http://www.regular-expressions.info/javascriptexample.html
^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[!@#\$%\^\&*\)\(+=._-])
 
Share this answer
 
Try this

/^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9]{3,15}$/;
 
Share this answer
 
 
Share this answer
 
Thanks all for suggestion but I tried following one and its works for me:

((?=.*[a-zA-Z])(?=.*\\d)(?=.*\\W)(.{8,20})$)
 
Share this answer
 

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