本文實例為大家分享了javaScript手機號碼校驗工具類PhoneUtils的具體代碼,供大家參考,具體內容如下
//PhoneUtils命名空間 PhoneUtils = { phoneRegexs: { //中國電信號碼段 CHINA_TELECOM_PATTERN: /^(?:/+86)?1(?:33|53|7[37]|8[019])/d{8}$|^(?:/+86)?1700/d{7}$/, //中國聯通號碼段 CHINA_UNICOM_PATTERN: /^(?:/+86)?1(?:3[0-2]|4[5]|5[56]|7[56]|8[56])/d{8}$|^(?:/+86)?170[7-9]/d{7}$/, //中國移動號碼段 CHINA_MOBILE_PATTERN: /^(?:/+86)?1(?:3[4-9]|4[7]|5[0-27-9]|7[8]|8[2-478])/d{8}$|^(?:/+86)?1705/d{7}$/, //電話座機號碼段 PHONE_CALL_PATTERN: /^(?:/d3,4|/d{3,4}-)?/d{7,8}(?:-/d{1,4})?$/, //手機號碼 PHONE_PATTERN: /^(?:/+86)?(?:13/d|14[57]|15[0-35-9]|17[35-8]|18/d)/d{8}$|^(?:/+86)?170[057-9]/d{7}$/, //手機號簡單校驗,不根據運營商分類 PHONE_SIMPLE_PATTERN: /^(?:/+86)?1/d{10}$/ }, //電話號碼 isPhoneCallNum: function(input) { return this.phoneRegexs.PHONE_CALL_PATTERN.test(input); }, //電信手機號碼 isChinaTelecomPhoneNum: function(input) { return this.phoneRegexs.CHINA_TELECOM_PATTERN.test(input); }, //中國聯通 isChinaUnicomPhoneNum: function(input) { return this.phoneRegexs.CHINA_UNICOM_PATTERN.test(input); }, //中國移動 isChinaMobilePhoneNum: function(input) { return this.phoneRegexs.CHINA_MOBILE_PATTERN.test(input); }, //手機號碼 isPhoneNum: function(input) { return this.phoneRegexs.PHONE_PATTERN.test(input); }, //手機號碼簡單校驗,只校驗長度 isPhoneNumBySize: function(input) { return this.phoneRegexs.PHONE_SIMPLE_PATTERN.test(input); } }; 以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VeVb武林網。
新聞熱點
疑難解答