Created
August 1, 2016 13:29
-
-
Save HarishChaudhari/0dd5514ce430991a1b1b8fa04e8b72a4 to your computer and use it in GitHub Desktop.
Password validation RegEx for JavaScript
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
/** | |
* Password validation RegEx for JavaScript | |
* | |
* Passwords must be | |
* - At least 8 characters long, max length anything | |
* - Include at least 1 lowercase letter | |
* - 1 capital letter | |
* - 1 number | |
* - 1 special character => !@#$%^&* | |
* | |
* @author Harish Chaudhari <harishchaudhari.com> | |
* | |
*/ | |
var str = "password"; // your password field's value goes here | |
/^(?=.*[\d])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*])[\w!@#$%^&*]{8,}$/.test(str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sweet, thank you!