以下是一个简单的JavaScript正则表达式,用于检验密码强度: ```javascript function checkPasswordStrength(password) { // 至少8个字符 if (password.length < 8) { return false; } // 包含数字、小写字母、大写字母和特殊字符 var regex = /^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#...
function checkPasswordStrength(password) { // 判断密码长度 if (password.length < 6) { ...
{ return '非常强'; } } // 测试密码强度 console.log(checkPasswordStrength('password')); // 输出: 弱 console.log(checkPasswordStrength('Password1')); // 输出: 中 console.log(checkPasswordStrength('Password#1')); // 输出: 强 console.log(checkPasswordStrength('P@ssw0rd!')); // 输出:...
}//checkStrong函数//返回密码的强度级别functioncheckStrong(sPW) {//密码长度if(sPW.length <= 4)return0;//密码太短Modes = 0;for(i = 0; i < sPW.length; i++) {//测试每一个字符的类别并统计一共有多少种模式.//目前未知|=的意思Modes |=CharMode(sPW.charCodeAt(i)); }returnbitTotal(Modes...
PasswordStrength.prototype.checkStrength=function(val){varaLvTxt = ['','低','中','高'];varlv = 0;if(val.match(/[a-z]/g)){lv++;}if(val.match(/[0-9]/g)){lv++;}if(val.match(/(.[^a-z0-9])/g)){lv++;}if(val.length < 6){lv=0;}if(lv > 3){lv=3;}this.oStrength...
function PasswordStrength(passwordID,strengthID){ this.init(strengthID); var _this = this; document.getElementById(passwordID).onkeyup = function(){ _this.checkStrength(this.value); } }; PasswordStrength.prototype.init = function(strengthID){ ...
case 1: return "弱密码"; case 2: case 3: return "中等密码"; case 4: case 5: return "强密码"; default: return "未知"; } } // 示例使用 const password = "Example@123"; const strength = checkPasswordStrength(password); console.log(`密码强度: ${getPasswordStrengthMessage(strength)}`...
PasswordStrength.prototype.checkStrength = function (val){ var aLvTxt = ['','低','中','高']; var lv = 0; if(val.match(/[a-z]/g)){lv++;} if(val.match(/[0-9]/g)){lv++;} if(val.match(/(.[^a-z0-9])/g)){lv++;} ...
functionPasswordStrength(passwordID,strengthID){this.init(strengthID);var_this =this;document.getElementById(passwordID).onkeyup=function(){ _this.checkStrength(this.value); } };PasswordStrength.prototype.init=function(strengthID){varid =document.getElementById(strengthID);vardiv =document.createElemen...
var PasswordStrength ={ Level : ["高,实在是高","还行啦","靠,这样也行"], LevelValue : [30,20,0],//强度值 Factor : [1,2,5],//字符加数,分别为字母,数字,其它 KindFactor : [0,0,10,20],//密码含几种组成的加数 Regex : [/[a-zA-Z]/g,/d/g,/[^a-zA-Z0-9]/g] //字符正...