Skip to content

Instantly share code, notes, and snippets.

@jorben
Created April 9, 2014 06:43
Show Gist options
  • Save jorben/10232736 to your computer and use it in GitHub Desktop.
Save jorben/10232736 to your computer and use it in GitHub Desktop.
分三级区分密码强度
/**
* 密码强度等级验证
*/
function valid_strong_password (password) {
if (password.length < 6 || parseInt(password) == password || /^[a-zA-Z]+$/.test(password) || /^[^a-zA-Z0-9]+$/.test(password)) {
return 0;
}
if (/^.{6,7}$/.test(password) || !/[0-9]/.exec(password) || !/[a-z]/.exec(password) || !/[A-Z]/.exec(password)) {
return 1;
}
return 2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment