Regular expressions javascript-VBForums
Results 1 to 2 of 2

Thread: Regular expressions javascript

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2008
    Posts
    1,260

    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

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,833

    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



    www.techreceipe.tk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.