惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 司徒正美
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
L
LangChain Blog
GbyAI
GbyAI
博客园_首页
V
Visual Studio Blog
Martin Fowler
Martin Fowler
WordPress大学
WordPress大学
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 叶小钗
腾讯CDC
博客园 - Franky
IT之家
IT之家
Google DeepMind News
Google DeepMind News
Microsoft Azure Blog
Microsoft Azure Blog
D
Docker
大猫的无限游戏
大猫的无限游戏
Recent Announcements
Recent Announcements
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
B
Blog
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - allonkwok

http header as3 打开窗口类 select 中使用 case when 和 replace Tomcat Server 原理 SVN 安装配置快速入门 JS中常用的xpath特性 天极网软件频道的用JS实现的图片切换特效 div动态展开和关闭 DOM属性速查 div+css兼容性问题 asp常用函数 Flash使用正则进行注册验证 javascript 获取URL参数 仿163弹出层 GridView 介绍 转:GridView 72般绝技 [作者:清清月儿] Javascript Unicode 编码和反编码函数 提取文章内容的纯文本,并截取一定的字数 javascrip动态时钟
手机号码验证的JS代码(包含153、159)
allonkwok · 2007-04-24 · via 博客园 - allonkwok

<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 onload=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" onsubmit="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>