javascript - 国际号码格式列表

标签 javascript jquery phone-number

我想构建一个验证器(javascript)来验证来自不同国家/地区的号码,

我希望能够使用这个骨架来调用它 phone('NZ', '049234567', false, false);

分别是“国家/地区前缀”、“号码”、“固定电话”、“国际”。

我将如何去做这样的事情?

目前我正在考虑做类似的事情

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]
            ]
        }
    }
}

最佳答案

关于javascript - 国际号码格式列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5240326/

相关文章:

regex - Oracle 正则表达式中的前瞻

angular - (Angular2/4/5/6)如何根据国家/地区验证国际电话号码的长度

javascript - 这个使用 Vue2 JS 的基本计算数据值有什么问题?

javascript - jsPDF : Uncaught (in Promise) Error: Could not load dompurify: Error: cannot find module 'dompurify' 的问题

javascript - Chartjs 3圆环图圆 Angular

jquery - 使用 jquery 粘性标题

c# - 如何将jquery添加到asp.net页面并格式化gridview列

javascript - 获取并设置最高位置

ios - objective-c - 如何判断 NSURL 是否被格式化为电话号码

javascript - SVG 暂停/播放 无法弄清楚为什么这不起作用...?