本文主要为大家详细介绍了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);
}
};
相关推荐:
完美实现身份证校验 js正则的方法
js校验图片尺寸的方法
什么是校验功能?校验功能实例用法汇总
以上就是javascript手机号码校验工具类phoneutils详解的详细内容。