Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

IE6 regex compatibility issue

Last post 12-17-2009, 8:37 AM by mays. 2 replies.
Sort Posts: Previous Next
  •  12-15-2009, 10:44 AM 57838

    IE6 regex compatibility issue

    This is about a strange behavior IE shows for a regex matching Im trying to do.

    Here is a password matching expression Im trying to use for matching the below conditions.

    • Must contain minimum 8 to 20 characters, mandatorily including one letter and number
    • May include only one of the following special characters: %,&, _, ?, #, =, -
    • Cannot have any spaces 

    ^(?=.{0,11}\d)(?=.{0,11}[a-zA-Z])[\w%&?#=-]{8,12}$

      and the javascript to do the match is

     function fnIsPassword(strInput){
      alert("strInput : " + strInput);
      var regExp =/^(?=.{0,11}\d)(?=.{0,11}[a-zA-Z])[\w%&?#=-]{8,12}$/;
      if(strInput.length > 0){
         return (regExp.test(strInput));
      }
      return false;
    }

    alert(fnIsPassword("1231231")); //false
    alert(fnIsPassword("sdfa4gggggg")); //FF: true, false in IE  
    alert(fnIsPassword("goog1234#")); //FF: true , false in IE

     

    The problem as stated above is that IE gives me false for the last 2 matches.

    My IE version is  6.0.2900.5512.xpsp_sp3_gdr.090804-1435 on win XP ; ScriptEngineMajorVersion() = 5 ScriptEngineMinorVersion() = 7.
    I got it reproduced on a colleague's machine with the same configuration.

    Somehow IE does the {8,12} count constraints after the first digit is matches.
    Thus i see that abc45678901 is matched and abc4567890 is not matched ( notice that the counting starts from he first digit match)

    Anyone can reproduce this issue ? Any workarounds ? .

    Thanks in advance,
    mays

  •  12-16-2009, 4:01 PM 57874 in reply to 57838

    Re: IE6 regex compatibility issue

  •  12-17-2009, 8:37 AM 57903 in reply to 57874

    Re: IE6 regex compatibility issue

    Thanks Micheal, I guess the original thread talks about the same animal. :)

    I have commented there about this.
    Just for the sake of it, here is my final regex , which works in IE and FF. 

     /(?=^[\w%&?#=-]{8,12}$)(?=.+\d)(?=.+[a-zA-Z]).+/

View as RSS news feed in XML