Reputation: 250
I'm using jquery's validator plugin to validate my registration form. I made a custom rule for password validation. I make it so that it has to follow the following rules:
1) Must be a minimum of 8 characters
2) Must contain at least 1 number
3) Must contain at least 1 symbol
4) Must contain at least 1 upper-case letter
Here's my code: fiddle
Including this expression:
/^(?=.*[\W])(?=.*[\d])(?=.*[A-Z]).{8,}$/i
This enforced almost all the above 4 policies except for the last one, it doesn't enforce that there must be at least 1 uppercase. I have no idea why, I've search all the regex documentations to make sure I got the syntax correct. And even this only tool tells me i'm right: ruby
Any ideas why it's not working properly? Thanks
Upvotes: 2
Views: 472
Reputation: 44279
The i
at the end of your regex makes it case insensitive. So every uppercase letter you specified will also match the corresponding lowercase letter. Remove that i
and it should work.
Upvotes: 7