Javascript regular expression password validation having special characters

后端 未结 7 715
闹比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:57

    I use the following script for min 8 letter password, with at least a symbol, upper and lower case letters and a number

    function checkPassword(str)
    {
        var re = /^(?=.*\d)(?=.*[!@#$%^&*])(?=.*[a-z])(?=.*[A-Z]).{8,}$/;
        return re.test(str);
    }
    

提交回复
热议问题