Javascript Tutorials

Javascript Phone Number Validation

NANP Phone Number Validation

Javascript Phone Number Validation for North America

North America Phone Number Validation in Forms

In forms when asking for phone numbers for North American countries (under the NANP) it is a good idea to use client side javascript validation along with your programming language validation. The following example shows how you can do this.

North American Numbering Plan (NANP)

The North American Numbering Plan (NANP) is an integrated telephone numbering plan of 24 countries and territories: the United States and its territories, Canada, Bermuda, and 16 Caribbean nations.

Please Note: Despite the "North American" name of the calling plan, Mexico, the Central American countries and some Caribbean nations are not part of the system.

A phone number in the NANP will start with a three-digit area code which is followed by a seven-digit telephone number that directs telephone calls to particular regions on a public switched telephone network (PSTN), where they are further routed by the local network.

We have also provided the javascript phone validation for the Internationl Phone number validation, U.S. number and General Phone Number validation using javascipt reular expresson.


Example of Phone Validation

Enter a Phone Number :


  • Valid Phone numbers:234 234 5678
  • Invalid Phone numbers:123 234 5678
  • Cut and Paste Code

    Cut 'n' paste code for the above Example

    JavaScript Code

    HTML Code

    Explanation of the Code

    The JavaScript has the following main functions:

    • Function checkInternationalPhone is used to verify if the given value is a possible valid international phone number : This function first removes all non-digit characters which are allowed in phone numbers. These delimiters are declared in the lines (found in the beginning of the code) :

      var phoneNumberDelimiters = "()- "
      var validWorldPhoneChars = phoneNumberDelimiters + "+"

      Now that all valid delimiters are removed we just check if the remaining value is an integer and that it has at least a certain number of digits (given by the variable 'minDigitsInIPhoneNumber').

    • Function ValidateForm is used to make sure that the phone number field is not blank and area code should be started between 2 and 9 and maximum digits should not be greater than 15 digits that it is a valid phone number on form submission
    Please like, +1, link to and share this SmartWebby resource if you found it helpful. Thanks!