Skip to content

Instantly share code, notes, and snippets.

@notgull
Created September 13, 2019 03:48
Show Gist options
  • Save notgull/1d8ed6fad237630e07fd231e747d75bb to your computer and use it in GitHub Desktop.
Save notgull/1d8ed6fad237630e07fd231e747d75bb to your computer and use it in GitHub Desktop.
var check_password_compat = function(pw) {
var ch, code;
var specialChars = ['-', '_', '?', '!'];
for (var i = 0; i < pw.length; i++) {
ch = pw[i];
code = ch.charCodeAt(ch);
var isUppercaseLetter = 65 <= code && code <= 90;
var isLowercaseLetter = 97 <= code && code <= 122;
var isNumber = 48 <= code && code <= 57;
var isSpecialChar = specialChars.indexOf(ch) !== -1;
if (!(isUppercaseLetter || isLowercaseLetter || isNumber || isSpecialChar)) return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment