Javascript regular expression password validation having special characters

后端 未结 7 712
闹比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:44

    If you check the length seperately, you can do the following:

    var regularExpression  = /^[a-zA-Z]$/;
    
    if (regularExpression.test(newPassword)) {
        alert("password should contain atleast one number and one special character");
        return false;
    } 
    

提交回复
热议问题