正则表达式判断手机号的运营商(电信移动联通)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/yyjdxgj/article/details/102739904
$tel=$('.tel').val().trim();
var res=checkMobile($tel);
                function checkMobile(telphone){
					      var isChinaMobile = /^((13[4-9])|(15([0-2]|[7-9]))|(18[2|3|4|7|8])|(178)|(147))[\d]{8}$/; //移动
					var isChinaUnion = /^((13[0-2])|(145)|(15[5-6])|(176)|(18[5-6]))[\d]{8}$/; //联通
					var isChinaTelcom = /^((133)|(153)|(18[0|1|9])|(177))[\d]{8}$/; //电信
					var isOtherTelphone  = /^170([059])\\d{7}$/;//其他运营商
					if(telphone.length !== 11){
					  return '未检测到正确的手机号码';
					}
					else{
					  if(isChinaMobile.test(telphone)){
					    return '移动';
					  }
					  else if(isChinaUnion.test(telphone)){
					    return '联通';
					  }
					  else if(isChinaTelcom.test(telphone)){
					    return '电信';
					  }
					  else if(isOtherTelphone.test(telphone)){
					    var num = isOtherTelphone.exec(telphone);
					    return '其他运营商';
					  }
					  else{
						return false;
					  }
					}
				}

猜你喜欢

转载自blog.csdn.net/yyjdxgj/article/details/102739904