这篇文章主要为大家详细介绍了javascript手机号码校验工具类phoneutils,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了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); } };
上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
在vue中常用组件和框架结构(详细教程)
在anime.js中如何实现动画效果的复选框
在fastclick代码中如何解决tap“点透”
使用vue时浏览器后退无法触发beforerouteleave的问题
在vue + element中如何实现表格分页
在vuerouter中如何使用导航守卫用法
以上就是在javascript中如何使用手机号码校验工具类phoneutils的详细内容。