I have written a regular expression which could potentially be used for password strength validation:
^(?:([A-Z])*([a-z])*(\\d)*(\\W)*){8,12}$
Check out this: http://jsfiddle.net/43tu58jf/
function isSimpleStrongLevel(password){
var stringsOptions = ['123456', '123abc', 'abc123', '654321', '012345', 'password', '123pass', 'pass123', '123456abc'];
return stringsOptions.indexOf(password) != -1;
}
function getStrongLevel(password) {
var level = 0;
level += password.length > 6 ? 1 : 0;
level += /[!@#$%^&*?_~]{2,}/.test(password) ? 1 : 0;
level += /[a-z]{2,}/.test(password) ? 1 : 0;
level += /[A-Z]{2,}/.test(password) ? 1 : 0;
level += /[0-9]{2,}/.test(password) ? 1 : 0;
return level;
}
var password = '123456';
var isSimple = isSimpleStrongLevel(password);
var level = getStrongLevel(password);
console.log(isSimple, level);