Created
October 28, 2014 03:46
-
-
Save sergeevabc/57008f2528599b781da0 to your computer and use it in GitHub Desktop.
Validate string against password policy via regex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rules: At leasst 1 uppercase, 1 lowercase, 1 digit, 1 special char from z85 alphabet | |
// Test: http://regex101.com/r/yP9aU6/1 | |
function validateResult(string) { | |
var regex = (/^(?=\S*?\w)(?=\S*?\d)(?=\S*?[.\-:+=^!\/*?&<>()\[\]{}@%$#])[0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.\-:+=^!/*?&<>()\[\]{}@%$#]+$/gm); | |
return regex.test(string); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment