I need to validate (and confirm) a new password on a site. There are criteria I need to test for, and I'm looking for the best method to do so, using jQuery.
The criteria are:
- Must have a minimum of 8 characters and a maximum of 12
- Should have at least three of the following: A. Upper case letter; B. Lower case letter; C. Numeric character; D. Punctuation.
EDIT: The following regexp is what I'm currently using to accomplish this.
regexp/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*(_|[^\w])).+$/
However, that checks to make sure that all four of those types are present, when I need only three out of the four (and it doesn't matter which three.) Can anyone suggest how to improve my regex to accomplish this?
UPDATE: I've still not figured out how to accomplish this, but have thought of a few scenarios. The way I see it is that it should be done using 5 permutations, and using AND and OR operators. However, I don't know how to do that in regex. Am I barking up the wrong tree?