<!DOCTYPE>
<html>
<head>
<title> New Document </title>
<meta charset="UTF-8">
<meta name="Generator"
content="EditPlus">
<meta name="Author"
content="">
<meta
name="Keywords" content="">
<meta name="Description"
content="">
<link
rel="stylesheet" type="text/css"
href="">
<script
type="text/javascript" src="jquery.js">
</script>
<style type="text/css">
div{color:red;height:25px;border:1px solid
#000;line-height:25px;}
</style>
</head>
<body>
<input type="text"
class="shuru">
<div
class="hao_div"></div>
<div class="operator">为了练习,手机号只有138,133,131号段</div>
</body>
<script type="text/javascript">
<!--
var
$oper_tex=$(".operator");
$(".shuru").keyup(function(){
var $inp_val
=
$(".shuru").val();
$(".hao_div").text($inp_val);
var $haoduan
=
$inp_val.substring(0,3);
//获取手机号前三位
if
($inp_val.length ==
11)
{
test2($haoduan);
}
else
if
($inp_val.length >
11)
{
$oper_tex.text("请输入正确手机号码")
}
else
if ($inp_val
==
"")
{
$oper_tex.text("")
}
});
function
test2(zhi){
var haoduan
=
{
"138":"1",
//中国移动
"131":"2",
//中国联通
"133":"3"
//中国电信
}
switch
(haoduan[zhi])
{
case
"1":
$oper_tex.text("中国移动");
break;
case
"2":
$oper_tex.text("中国联通");
break;
case
"3":
$oper_tex.text("中国电信");
break;
}
}
//-->
</script>
</html>
1 中国移动 134.135.136.137.138.139.150.151.152.157.158.159.187.188 ,147(数据卡)
- 2 中国联 通130.131.132.155.156.185.186
- 3 中国电信133.153.180.189
- 4 CDMA 133,153
- 5
- 6 正 则如下:
- 7
- 8 /// <summary>
- 9 /// 匹配移动手机号
- 10 /// </summary>
- 11 public const string PATTERN_CMCMOBILENUM = @"^1(3[4-9]|5[012789]|8[78])\d{8}$";
- 12 /// <summary>
- 13 /// 匹配电信手机号
- 14 /// </summary>
- 15 public const string PATTERN_CTCMOBILENUM = @"^18[09]\d{8}$";
- 16 /// <summary>
- 17 /// 匹配联通手机号
- 18 /// </summary>
- 19 public const string PATTERN_CUTMOBILENUM = @"^1(3[0-2]|5[56]|8[56])\d{8}$";
- 20 /// <summary>
- 21 /// 匹配CDMA手机号
- 22 /// </summary>
- 23 public const string PATTERN_CDMAMOBILENUM = @"^1[35]3\d{8}$";
1 中国移动 134.135.136.137.138.139.150.151.152.157.158.159.187.188 ,147(数据卡) 2 中国联 通130.131.132.155.156.185.186 3 中国电信133.153.180.189 4 CDMA 133,153 5 6 正 则如下: 7 8 /// <summary> 9 /// 匹配移动手机号 10 /// </summary> 11 public const string PATTERN_CMCMOBILENUM = @"^1(3[4-9]|5[012789]|8[78])\d{8}$"; 12 /// <summary> 13 /// 匹配电信手机号 14 /// </summary> 15 public const string PATTERN_CTCMOBILENUM = @"^18[09]\d{8}$"; 16 /// <summary> 17 /// 匹配联通手机号 18 /// </summary> 19 public const string PATTERN_CUTMOBILENUM = @"^1(3[0-2]|5[56]|8[56])\d{8}$"; 20 /// <summary> 21 /// 匹配CDMA手机号 22 /// </summary> 23 public const string PATTERN_CDMAMOBILENUM = @"^1[35]3\d{8}$";
JavaScript:
- //移除电信号码
- var reg = /^1(3[3]|5[3]|8[019])\d{8}$/;
- if (!reg.test(v)) {
- // alert("是");
- }
//移除电信号码 var reg = /^1(3[3]|5[3]|8[019])\d{8}$/; if (!reg.test(v)) { // alert("是"); }
- //移除联通号码
- var reg = /^1(3[0-2]|4[57]|5[56]|8[56])\d{8}$/;
- if (!reg.test(v)) {
- // alert("是");
- }
//移除联通号码 var reg = /^1(3[0-2]|4[57]|5[56]|8[56])\d{8}$/; if (!reg.test(v)) { // alert("是"); }
- //移除移动号码
- var reg = /^1(3[4-9]|5[012789]|8[2378])\d{8}$/;
- if (!reg.test(v)) {
- // alert("是");
- }
//移除移动号码 var reg = /^1(3[4-9]|5[012789]|8[2378])\d{8}$/; if (!reg.test(v)) { // alert("是"); }
- //去除错误号码
- var reg = /^1(3[0123456789]|4[57]|5[012356789]|8[127856039])\d{8}$/;
- if (reg.test(v)) { //是包含在内的就是正确的手机号码
- }