Password regex works in chrome and firefox, but not IE7
The following regular expression works in chrome and firefox, but not IE7:
^((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,20})$
It needs to contain at least 8 characters and have at least on uppercase and a number. When I try this in IE7, I have to type 14 characters for it to validate. Can someone explain why and what would be the correct expression for all 3 browsers.
I am using an asp:开发者_如何学编程RegularExpressionValidator to validate the password.
been asked before:
Change Password Control RegEx validating oddly in IE 7 only
str.length > 8
/[A-Z]/
/\d/
Three checks vs. one monster regex. Which is easier to read and doesn't cause issues in IE?
if( str.length > 8 && str.search(/[A-Z]/) != -1 && str.search(/\d/) != -1 )
{
//Don't use big long regex when you don't need it
}
精彩评论