DotNetDublin
DotNetDublin

Reputation: 798

Regular Expression Help for Internet Explorer 7

Regular Expressions aren't my strong point but I had been using the below to validate Passwords were between 8 and 20 characters and had at least one digit and one upper and lower case character.

((?=.*\d)(?=.*[A-Z])(?=.*[a-z]).{8,20})

All was working fine until I tested in Internet Explorer which was returning all passwords as invalid.

This is due to the Internet Explorer 7 bug described here IE7 regex issue - Regex that work in every browser does not work in ie7

Following the blog posts on the above questions I see some people say that in most cases the regular expression can be reworked so that it works on IE7 but as I say my regular expression knowledge isn't the best so if anyone new how to make the above work on IE7 that would be great.

I am using ASP.NET so another option is to set EnableClientScript to False so that the regular expression is checked server side but I'd rather have it checked client side first if possible.

Upvotes: 2

Views: 168

Answers (1)

Loamhoof
Loamhoof

Reputation: 8293

Just looking at the link you posted. And here you go:

/((?=.{8,20})(?=.*\d)(?=.*[A-Z])(?=.*[a-z]).*)/

Also, following the same link, this should work as well:

/((?=.+\d)(?=.+[A-Z])(?=.+[a-z]).{8,20})/

Upvotes: 1

Related Questions