判斷密碼至少8位包含大小寫字母,數字,特殊符號四選三
阿新 • • 發佈:2019-02-01
function validatePassWord(pwd){
/*var zhenze=new RegExp("^(?![a-zA-Z]+$)(?![a-z\d]+$)(?![[email protected]#\$%]+$)(?![A-Z\d]+$)(?![[email protected]#\$%]+$)(?![\[email protected]#\$%]+$)[a-zA-Z\[email protected]#\$%]+$");if(zhenze.test(pwd)){
return true;
}
return false; */
pwd = $("#newPassWord").val();
}
var regUpper = /[A-Z]/;
var regLower = /[a-z]/;
var regNum = /[0-9]/;
var regTeShu =new RegExp("[`[email protected]#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]");
var complex = 0;
if (regLower.test(pwd)) {
++complex;
}
if (regUpper.test(pwd)) {
++complex;
}
if (regNum.test(pwd)) {
++complex;
}
if(regTeShu.test(pwd)){
++complex;
}
if (complex < 3 || pwd.length < 8) {
document.getElementById("checkpwd").innerHTML = "<div class='control-label red'>密碼不符合要求</div>";
return false;
} else {
document.getElementById("checkpwd").innerHTML = "<div class='control-label green'>密碼符合要求</div>";
return true;
}
}