js中验证密码是否是弱密码的4个方法 密码至少包含小写字母、大写字母、数字、特殊字符中的3类密码长度至少8位

//验证密码是否是弱密码的4个方法 密码至少包含小写字母、大写字母、数字、特殊字符中的3类

//  /g表示全局
function isContainNum(pwd){
return pwd.match(/d+/g)==null ? false : true; } function isContainLowChar(pwd){ return pwd.match(/[a-z]+/g)==null ? false : true; } function isContainUpChar(pwd){ return pwd.match(/[A-Z]+/g)==null ? false : true; } function isContainEspChar(pwd){ return pwd.match(/[~!@#$%^&*()_=+]+/g)==null ? false : true; } //判断用户输入的密码是否是弱密码 function checkPassword(password){ if(isContainNum(password)&&isContainLowChar(password)&&isContainUpChar(password)){ return true; }else if(isContainNum(password)&&isContainLowChar(password)&&isContainEspChar(password)){ return true; }else if(isContainNum(password)&&isContainUpChar(password)&&isContainEspChar(password)){ return true; }else if(isContainLowChar(password)&&isContainUpChar(password)&&isContainEspChar(password)){ return true; }else{ return false; } }



原文地址:https://www.cnblogs.com/xiaotang5051729/p/9674884.html