views:

229

answers:

4

Hi all

I got a regex-validator on my asp.net page, which validates a password. The regex is

^(?=.*[0-9])(?=.*[a-zæøåA-ZÆØÅ])[a-zA-ZæøåÆØÅ0-9]{6,}$

.. Now, it works fine in IE8 and FF3, but it validates to false no matter what I try in IE7. Are there any knows bugs, I should know about here? :S

Thanks in advance..

A: 

Looks like you are having some encoding issues with your example there. Unless you absolutely have to have it on the client side, I recommend using a CustomValidator that validates on that executes your logic via the OnServerValidate event handler. Validating on the server side keeps you out of the javascript regular expressions cross browser compatability weirdness.

craigmoliver
+1  A: 

You need to encode your entities. Try the following:

^(?=.*[0-9])(?=.*[a-z\xE6\xF8\xE5A-Z\xC6\xD8\xC5])[a-zA-Z\xE6\xF8\xE5A-Z\xC6\xD8\xC50-9]{6,}$
Andrew Moore
A: 

Seems like IE7 doesn't like the {6,} at the end of the string. Found some articles about this around the web. Anyway, the solution was to put it in a region by itself :)

^(?=.{6,}$)(?=.*[0-9])(?=.*[a-zæøåA-ZÆØÅ])[a-zA-ZæøåÆØÅ0-9]*
cwap
It isn't the `{6,}` that's causing the problem, it's the lookaheads. Steve Levithan, with help from Jan Goyvaerts, did a good job of dissecting the bug in Steve's blog: http://blog.stevenlevithan.com/archives/regex-lookahead-bug
Alan Moore
A: 

I also had problems with Internet Explorer 7.

Here is what I was able to use, to require 8 characters, with a digit and number (allowing spaces):

(?!^[0-9]*$)(?!^[ a-zA-Z!@#$%^&amp;*()_+=<&gt;?]*$)^([ a-zA-Z!@#$%^&amp;*()_+=<&gt;?0-9]{8,20})$
Glen Little