当前位置: 移动技术网 > IT编程>开发语言>JavaScript > javaScript手机号码校验工具类PhoneUtils详解

javaScript手机号码校验工具类PhoneUtils详解

2018年03月04日  | 移动技术网IT编程  | 我要评论
本文实例为大家分享了javascript手机号码校验工具类phoneutils的具体代码,供大家参考,具体内容如下 //phoneutils命名空间 phon

本文实例为大家分享了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); 
 } 
}; 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网