Javascript regular expression password validation having special characters

后端 未结 7 714
闹比i
闹比i 2020-12-12 17:14

I am trying to validate the password using regular expression. The password is getting updated if we have all the characters as alphabets. Where am i going wrong ? is the re

7条回答
  •  春和景丽
    2020-12-12 17:39

    Regex for password:

    /^(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[a-zA-Z!#$%&? "])[a-zA-Z0-9!#$%&?]{8,20}$/

    Took me a while to figure out the restrictions, but I did it!

    Restrictions: (Note: I have used >> and << to show the important characters)

    1. Minimum 8 characters {>>8,20}
    2. Maximum 20 characters {8,>>20}
    3. At least one uppercase character (?=.*[A-Z])
    4. At least one lowercase character (?=.*[a-z])
    5. At least one digit (?=.*\d)
    6. At least one special character (?=.*[a-zA-Z >>!#$%&? "<<])[a-zA-Z0-9 >>!#$%&?<< ]

提交回复
热议问题