JS检测密码强度
2012-10-11 16:09:02 来源:WEB开发网核心提示:function _getPasswordStrength(password) { return 0 // if password bigger than 5 give 1 point + +(password.length > 5) // if password
function _getPasswordStrength(password) { return 0 // if password bigger than 5 give 1 point + +(password.length > 5) // if password has both lower and uppercase characters give 1 point + +(/[a-z]/.test(password) && /[A-Z]/.test(password)) // if password has at least one number and at least 1 other character give 1 point + +(/\d/.test(password) && /\D/.test(password)) // if password has a combination of other characters and special character give 1 point + +(/[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/.test(password) && /\w/.test(password)) // if password bigger than 12 give 1 point + +(password.length > 12); }; console.log(_getPasswordStrength('asdfASDF12 341542$$@#!$'));
赞助商链接