After scouring for answers on this, it seems that IE just fails.
Indeed, if you run some version of IE and try the examples here:
http://www.the-art-of-web.com/javascript/validate/1/ you'll see epic
fail.

So, I want to use http://xregexp.com/api/ instead for all my regex
handling in my project, but I'm not totally clear on the recommended
path for including an external JS library in a GWT project -- anyone
have a pointer/link?

On Aug 14, 11:10 am, davis <[email protected]> wrote:
> Hi Dominik, I also use other regex for other text boxes and they have
> double-slashes and they work.
>
> For example I have another textbox which validates against this regex:
>
> public static final String REGEX_PINCODE = "[\\w]{12}";
>
> That one has no problem in IE or Firefox.
>
> I tried changing the original problematic regex to this (to avoid
> double slash altogether):
>
> ^(?=.*[0-9])(?=.*[a-z]).{8,15}$
>
> But the problem still remains for IE.  I don't have a lot of insight
> into this issue.  I just installed the DebugToolbar, and now I will re-
> compile it all with readable JavaScript to see if I can spot anything,
> but I'm drawing a blank on this one.  I'm not much of a javascript
> maven.  If anyone has any insight, I'd be thrilled to hear it.
>
> Regards,
> Davis
>
> On Aug 14, 10:57 am, Dominik Steiner
>
> <[email protected]> wrote:
> > Hi davis,
>
> > I'm using the following regex to match addresses in the format of 123
> > west road
>
> >                         public static final String ADDRESS_REGEX = 
> > "[0-9]+\\s*\\D+";
>
> > and it works fine on IE too. Note the double slash before s and D
>
> > So I don't think that the double slash is the problem.
>
> > HTH
>
> > Dominik
>
> > davis schrieb:
>
> > > I think I figured out the problem, using an online regex tester for
> > > JavaScript:http://www.pagecolumn.com/tool/regtest.htm
>
> > > Note that the regex translation in JavaScript has a double backslash
> > > to escape the \d special character.  This fails standard regex test
> > > for JavaScript for inputs like abcd1234.
>
> > > ^(?=.*\\d)(?=.*[a-z]).{8,15}$
>
> > > If you replace the regex text with:
>
> > > ^(?=.*\d)(?=.*[a-z]).{8,15}$
>
> > > Then it works for JavaScript.  However, Java requires the character to
> > > be escaped.  I'm guessing Firefox simply interprets \\d as \d, which
> > > is why it passes, but IE is not as forgiving.  This seems like a bug
> > > in the GWT compiler.  It seems to me it should take the \\d and
> > > translate it to \d when compiling from Java to JavaScript.
>
> > > Can someone confirm?
>
> > > Regards,
> > > Davis
>
> > > On Aug 14, 9:44 am, davis <[email protected]> wrote:
> > > > Hi, I have the following Java code to validate a password box.
> > > > Basically it checks that the password can't be null, is between 8-15
> > > > characters, and must contain both numbers and letters.
>
> > > > public static boolean validatePassword(PasswordTextBox box, Label
> > > > errorLabel) {
> > > >                 String text = box.getText();
> > > >                 if(text.isEmpty()) {
> > > >                         ValidatorUtil.onFailure(box, 
> > > > custom.passwordMayNotBeNull(),
> > > > errorLabel);
> > > >                         return false;
> > > >                 } if(text.length() < 8 || text.length() > 15) {
> > > >                         ValidatorUtil.onFailure(box, 
> > > > custom.passwordHasInvalidLength(8, 15,
> > > > text.length()), errorLabel);
> > > >                         return false;
> > > >                 } if(!text.matches(CustomMessages.REGEX_PASSWORD)) {
> > > >                         ValidatorUtil.onFailure(box, 
> > > > custom.passwordHasInvalidFormat(),
> > > > errorLabel);
> > > >                         return false;
> > > >                 }
> > > >                 return true;
> > > >         }
>
> > > > This works fine in Firefox, but it does not work in IE.  The
> > > > JavaScript compiles down to this for IE8:
>
> > > > function validatePassword(box, errorLabel){
> > > >   var text, matchObj;
> > > >   text = $getPropertyString(box.element, 'value');
> > > >   if (!text.length) {
> > > >     setStyleName(box.element, 'validationFailedBorder', true);
> > > >     ($clinit_114() , errorLabel.element).innerText = 'You must provide
> > > > a password.';
> > > >     return false;
> > > >   }
> > > >   if (text.length < 8 || text.length > 15) {
> > > >     onFailure_1(box, 'Sorry, your password must be between 8 and 15
> > > > characters long (you have ' + text.length + ' characters).',
> > > > errorLabel);
> > > >     return false;
> > > >   }
> > > >   if (!(matchObj = (new RegExp('^(?=.*\\d)(?=.*[a-z]).{8,15}$')).exec
> > > > (text) , matchObj == null?false:text == matchObj[0])) {
> > > >     setStyleName(box.element, 'validationFailedBorder', true);
> > > >     ($clinit_114() , errorLabel.element).innerText = 'Sorry, your
> > > > password must contain both letters [a-z] and numbers [0-9].';
> > > >     return false;
> > > >   }
> > > >   return true;
>
> > > > }
>
> > > > The behavior is a bit odd.  It passes the text.length checks, but then
> > > > fails the regex expression (which also has length checks with {8,15}.
> > > > It always prints: 'Sorry, your password must contain both letters [a-
> > > > z] and numbers [0-9].' in IE, but in Firefox, it works fine...for
> > > > inputs like this:
>
> > > > abcd1234 <- valid password, 8 characters with letters and numbers
>
> > > > Even more strange is the fact that if I enter a password with 12
> > > > characters with both letters and numbers, IE passes, like this:
>
> > > > abcd1234abcd
>
> > > > But if I enter only 11 characters, it fails:
>
> > > > abcd1234abc
>
> > > > Any clues on what is wrong here?
>
> > > > Regards,
> > > > Davis
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to