I am trying to create a javascript regular expression for password validation. The rules for a password to get accepted are
- Should contain 12 characters or more
- Should contain one of these special characters
* ^ !
- At least two uppercase characters
- At least two numbers
- At least one lowercase characters
I found an example online and modified it like following
(?=.*[0-9]{2,})(?=.*[a-z])(?=.*[A-Z]{2,}).{12,}
However this still misses the special character requirement and only works if the upper case characters and numbers are in subsequent order. These are the results I got with this one
aMMericano11 - true
aMmeRican1o1 - false
I wanted the second one to be accepted too with the addition of special characters of course.
Can anyone help me on this?