Skip to content

Instantly share code, notes, and snippets.

@ziyahan
Created April 3, 2015 12:27
Show Gist options
  • Save ziyahan/08d98b806743b14d2356 to your computer and use it in GitHub Desktop.
Save ziyahan/08d98b806743b14d2356 to your computer and use it in GitHub Desktop.
Test Passwd
testPassword = function (password) {
var minLengthMet = password.length >= 8,
hasUpper = (/[A-Z]+/).test(password),
hasLower = (/[a-z]+/).test(password),
hasNumber = (/[0-9]+/).test(password),
letterBegin = (/^[A-Za-z]/).test(password),
noSpecials = !(/[^A-Za-z0-9]+/).test(password);
logIndividualTests(minLengthMet, hasUpper, hasLower, hasNumber, letterBegin, noSpecials);
return minLengthMet && hasUpper && hasLower && hasNumber && letterBegin && noSpecials;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment