LittlBUGer
Programmer
Hello. I've been trying to get passwords on new user registrations restricted to have at least 1 uppercase letter, 1 lowercase letter, 1 number, no spaces, and be a minimum of 8 characters long. I'm pretty positive I've got the right regular expression (I got it off of regexlib.com) but for some reason it just does not want to work properly. Here's the expression:
And here's the code for the control (textbox):
Now, on the page, when I try to enter something like, Password12, it doesn't work. It DOES work if I change the {8,} to {2,} which makes no sense to me. Then when I try to use passord12W, it does NOT work, like it can't handle the uppercase letter at the end.
All I want is to be able to handle a password with at least 1 uppercase, 1 lowercase, and 1 number and no spaces, in ANY order, being at least 8 characters long. Can someone please help me here? I've tried so many different combinations now I'm starting to lose track which is what. Thanks.
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein
Code:
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$
And here's the code for the control (textbox):
Code:
<asp:TextBox ID="password" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="password" ErrorMessage="*" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" ValidationExpression="^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$" ControlToValidate="password" runat="server" ErrorMessage="!" />
Now, on the page, when I try to enter something like, Password12, it doesn't work. It DOES work if I change the {8,} to {2,} which makes no sense to me. Then when I try to use passord12W, it does NOT work, like it can't handle the uppercase letter at the end.
All I want is to be able to handle a password with at least 1 uppercase, 1 lowercase, and 1 number and no spaces, in ANY order, being at least 8 characters long. Can someone please help me here? I've tried so many different combinations now I'm starting to lose track which is what. Thanks.
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein