验证手机号码

来源:互联网 发布:路飞 知乎 编辑:程序博客网 时间:2024/06/10 05:52
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="keywords" content="软件破解,网络安全,SEO,网站建设" />
<meta name="description" content="www.niuair.com,精通软件破解,网络安全,SEO,网站建设" />
<script>
function checkMobile(obj){
if (document.oray.UserMobile.value != ""){   
var mobile=document.oray.UserMobile.value;   
var IsMobilePhone = /^((\(\d{3}\))|(\d{3}\-))?(13\d{9}$)|(15\d{9}$)|(18\d{9}$)/;
var my = false;   
if (IsMobilePhone.test(mobile)) my=true;   
 
if (!my){   
document.oray.UserMobile.value='';   
alert('对不起,您输入的手机号码有错误。');   
document.oray.UserMobile.focus();   
return false;   
}   
return true;   
}   
}
</script>

<title>验证手机号码是否正确。</title>

</head>



<body>
<h1>验证手机号码是否正确</h1><hr>


<form name="oray">
请输入手机号码:<input type="text" name="UserMobile" maxlength="11"><input type="button" value="验证" onclick="checkMobile(document.oray.UserMobile.value)">
</form>
</body>
</html>