Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE6 regular expression bug?

Status
Not open for further replies.

ajliles

Programmer
Mar 8, 2002
10
GB
Hi everyone,

I'm trying to use regular expressions in javascript to validate an international phone number, and I can't get the regular expression to test for +.
The pattern I'm using is:
/^(\+)\d{1,3} [\d ]+\d$/
I think this is a bug because if I use the following pattern, it accepts $nnn nnn nnnnn:
/^(\$)\d{1,3} [\d ]+\d$/
So it seems there's a problem escaping the + character - I'ev also tried using hex values, ie \x2b which also doesn't work.

Anyone had similar problems? Any help would be much appreciated.

Thanks.
Adrian.

aliles@arrowuk.com
 
Try this :

// | i18n code | area code | city number | optional extension
var telephoneNumber = /^(\+\d{1,3}[ -\.]?)?(\(\d{1,5}\)|\d{1,5})[ -\.]?\d{2,4}[ -\.]?\d{0,7}( ?e?xt ?\d{1,5})?/i;

I hope this helps. Gary Haran
 
Thanks for the reply, but still no luck!

Using your pattern I can enter the following and it works fine:

(11) 11 11 ext 11

but when I try the following it fails:

+11 (11) 11 11 ext 11

So for some reason I have a problem when the user tries entering the + sign. Escaping with \+ doesn't allow me to enter +, but escaping with \$ does allow me to enter $.

Weird eh? I'm using IE6 and believe this must be a bug, but can't find anything in MSDN/Knowledge base, and it's driving me crazy!

Adrian.
 
Just tried this on IE5 and it doesn't work :-(

Adrian
 
I've now got it working - I found out that certain characters were being stripped (in a function called from a parent frame) before getting to my validation function :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top