-
Apr 16th, 2012, 01:31 AM
#1
Thread Starter
Frenzied Member
Regular expressions javascript
I am validating a web page via a javascript function using regular expressions. Here is my variable:
var RE_phone = /^[\d\+]{3,4}([\- ]?)\d{1,3}([\- ]?)\d{3}([\- ]?)\d{4}$/;
I am needing it to validate both national and international numbers. So far it is working correctly, except for national numbers.
Here is an example of a national number that I would like to be able to accept as a valid number: 04 4784897 or 044784897.
Can I please have some help to modify my regular expression variable to accept national phone numbers in the above format?
thanks
-
Apr 16th, 2012, 01:38 AM
#2
Re: Regular expressions javascript
From here
Code:
Title Test Details Pattern Title
Expression
^(\+[1-9][0-9]*(\([0-9]*\)|-[0-9]*-))?[0]?[1-9][0-9\- ]*$
Description
International phone number check - optional country code followed by area code surrounded with '-' or '(' and ')', or just an area code optionally starting with 0, followed by phone numder. The number itself may contain spaces and '-'
Matches
+123(45)678-910 | +123-045-67 89 10 | 01-234-56-78
Non-Matches
123(45)678 91011 | (12)345-678 | +0(12)345-6789
Please mark you thread resolved using the Thread Tools as shown
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|