Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4039182
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:34:24+00:00 2026-05-20T12:34:24+00:00

I am wanting to build a validator (javascript) that can validate numbers from different

  • 0

I am wanting to build a validator (javascript) that can validate numbers from different countries,

I want to be able to call it using this skeleton phone('NZ', '049234567', false, false);

which is ‘COUNTRY PREFIX`, ‘NUMBER’, ‘LANDLINE’, ‘INTERNATIONAL’.

How would I go about doing such a thing?

Currently I am thinking of having something like

var phones = {
    NZ: {
        national: {
            landline: [
                '03{2,9}n(6)',  //read as 03[a number between 2 and 9][a random number][repeat previous expression 6 times]
                '04{2,9}n(6)',  //read as 04[a number between 2 and 9][a random number][repeat previous expression 6 times]
                '06{2,9}n(6)',  //read as 06[a number between 2 and 9][a random number][repeat previous expression 6 times]
                '07{2,9}n(6)',  //read as 07[a number between 2 and 9][a random number][repeat previous expression 6 times]
                '09{2,9}n(6)'   //read as 09[a number between 2 and 9][a random number][repeat previous expression 6 times]
            ],
            mobile: [
                '020n(7,10)', //read as 020[a random number][repeat previous expression between 7 and 10 times]
                '021n(7,10)', //read as 021[a random number][repeat previous expression between 7 and 10 times]
                '022n(7,10)', //read as 022[a random number][repeat previous expression between 7 and 10 times]
                '027n(7,10)', //read as 027[a random number][repeat previous expression between 7 and 10 times]
                '029n(7,10)'  //read as 029[a random number][repeat previous expression between 7 and 10 times]
            ]
        },
        international: {
            landline: [
                '+643{2,9}n(6)',  //read as +643[a number between 2 and 9][a random number][repeat previous expression 6 times]
                '+644{2,9}n(6)',  //read as +644[a number between 2 and 9][a random number][repeat previous expression 6 times]
                '+646{2,9}n(6)',  //read as +646[a number between 2 and 9][a random number][repeat previous expression 6 times]
                '+647{2,9}n(6)',  //read as +647[a number between 2 and 9][a random number][repeat previous expression 6 times]
                '+649{2,9}n(6)'   //read as +649[a number between 2 and 9][a random number][repeat previous expression 6 times]
            ],
            mobile: [
                '+6420n(7,10)',  //read as +6420[a random number][repeat previous expression between 7 and 10 times]
                '+6421n(7,10)',  //read as +6421[a random number][repeat previous expression between 7 and 10 times]
                '+6422n(7,10)',  //read as +6422[a random number][repeat previous expression between 7 and 10 times]
                '+6427n(7,10)',  //read as +6427[a random number][repeat previous expression between 7 and 10 times]
                '+6429n(7,10)'   //read as +6429[a random number][repeat previous expression between 7 and 10 times]
            ]
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:34:25+00:00Added an answer on May 20, 2026 at 12:34 pm

    See: http://en.wikipedia.org/wiki/List_of_country_calling_codes

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wanting to access a website from a different port than 80 or
I want to build a windows service that will use a remote encoding service
I am wanting to build a Kynetx app that does a datasource query once
I'm new to coding in general, and I'm wanting to build a website that
I'm trying to build a project in JavaScript that utilizes HTML5's canvas tag. However,
I'm wanting to build an application that will tell me how far I've ran.
I have been wanting to build my own box with AMD 6 core. I
I'm trying to build a PHP site and I'm wanting to test my PHP
I'm trying to build a hit counter for different parts of the website in
So I'm wanting to implement the TinyMce helper. I've followed instructions from the cakephp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.