By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,900 Members | 1,078 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,900 IT Pros & Developers. It's quick & easy.

IE7 having problems with regular expressions

P: n/a
Some of my regular expressions don't seem to work correctly in IE7. I am on
asp.net 1.1.

I have a site that has been up for a while and I started having problems on
machines with IE7. IE5 and IE6 seem to work fine.

In the following - 919-111-2222 as well as (919)111-2222 was giving one of
my clients the error message and IsValidate was set to false.

<asp:RegularExpressionValidator runat="server"
ErrorMessage=" Phone not in standard format"
Display="Dynamic"
ControlToValidate="Phone"
ValidationExpression="^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[-
..]?\d{3}[- .]?\d{4}$" />

In the following, ts*@aol.com gave him an error.

<asp:RegularExpressionValidator
ControlToValidate="email"
Display="Dynamic"
Text = "<br Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}"
runat="server" />

These worked fin on IE5 and IE6 as well as Mozilla and Firefox.

I am getting the error when leaving the field so I assume it has something
to do with MS' javascript code.

Is this a known problem or do I need to do something to make this work
correctly?

Thanks,

Tom
Oct 3 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
The first thing that pops out at me is the email address of the client,
which is an AOL email address. This indicates that in all likelyhood the
user is not skilled with computers.

The second thing is the 2 anchors, one at the beginning, and one at the end,
indicating that the match must begin at the start of the string, and end at
the end of the string. Therefore,

"919-111-2222" and "(919)111-2222" will match, but
" 919-111-2222" and "(919)111-2222 " will not match, since they have spaces
either at the beginning or at the end. Neither will
"\n919-111-2222" and "(919)111-2222\n" because they have newline characters
at the beginning or at the end.

It might be safer and less trouble for you to omit these characters, or
perhaps replace them with white-space character classes, as in:

\s*[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[-.]?\d{3}[- .]?\d{4}\s*

This indicates that 0 or more white space characters may precede or follow
the value. You can always trim them on the server.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

A watched clock never boils.

"tshad" <ts**********@ftsolutions.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Some of my regular expressions don't seem to work correctly in IE7. I am
on asp.net 1.1.

I have a site that has been up for a while and I started having problems
on machines with IE7. IE5 and IE6 seem to work fine.

In the following - 919-111-2222 as well as (919)111-2222 was giving one of
my clients the error message and IsValidate was set to false.

<asp:RegularExpressionValidator runat="server"
ErrorMessage=" Phone not in standard format"
Display="Dynamic"
ControlToValidate="Phone"
ValidationExpression="^[01]?[- .]?(\([2-9]\d{2}\)|[2-9]\d{2})[-
.]?\d{3}[- .]?\d{4}$" />

In the following, ts*@aol.com gave him an error.

<asp:RegularExpressionValidator
ControlToValidate="email"
Display="Dynamic"
Text = "<br Invalid Email Address!"
ValidationExpression="\S+@\S+\.\S{2,3}"
runat="server" />

These worked fin on IE5 and IE6 as well as Mozilla and Firefox.

I am getting the error when leaving the field so I assume it has something
to do with MS' javascript code.

Is this a known problem or do I need to do something to make this work
correctly?

Thanks,

Tom

Oct 3 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.