Javascript regular expression password validation having special characters

后端 未结 7 731
闹比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:38

    you can make your own regular expression for javascript validation

        /^            : Start
        (?=.{8,})        : Length
        (?=.*[a-zA-Z])   : Letters
        (?=.*\d)         : Digits
        (?=.*[!#$%&? "]) : Special characters
        $/              : End
    
    
    
            (/^
            (?=.*\d)                //should contain at least one digit
            (?=.*[a-z])             //should contain at least one lower case
            (?=.*[A-Z])             //should contain at least one upper case
            [a-zA-Z0-9]{8,}         //should contain at least 8 from the mentioned characters
    
            $/)
    
    Example:-   /^(?=.*\d)(?=.*[a-zA-Z])[a-zA-Z0-9]{7,}$/
    

提交回复
热议问题