手机号码验证的JS代码(包含153、159)

<script language="javascript" type="text/javascript">
<!--
function h()
{
document.mobileform.mobile.focus();
}
function checkMobile()
{
 var mobile=document.mobileform.mobile.value;
 var reg0=/^13/d{5,9}$/;   //130--139。至少7位
 var reg1=/^153/d{4,8}$/;  //联通153。至少7位
 var reg2=/^159/d{4,8}$/;  //移动159。至少7位
 var my=false;
 if (reg0.test(mobile))my=true;
 if (reg1.test(mobile))my=true;
 if (reg2.test(mobile))my=true;
 if (!my){
 document.mobileform.mobile.value='';
 alert('对不起,您输入的手即号码错误。');
 document.mobileform.mobile.focus();}
 return my;
}
//-->
</script>

 

<style type="text/css">
<!--
body,td,th {}{
 font-size: 12px;
}
-->
</style>

 

<body οnlοad=h()>
因为手机号码归属地查询只需要前7位就足够了,所以长度至少是7<br>
要严格验证11位的话将{5,9}、{4,8}换成{8}即可!<br><br>
<form action="http://www.j55.cn/mobile/index.asp" method="post" name="mobileform" target="_blank" id="mobileform" οnsubmit="return checkMobile()">
            <span style="color:#000000">手机号码:</span>      
            <input name="mobile" type="text" id="mobile" size="20" maxlength="16" value="">
            <input name="post" type="hidden" value="ok">
            <input name="Submit" type="submit" class="style5" value="我要查询">
        <input name="Submit2" type="reset" class="style5" value="重置">
    </form>
</body>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值