- 手机号码验证
发布时间:2010-01-04 类别:javascript技术 来源:侠客工作室 -
- 1
- 2
- 3
- 4
- 5
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>手机号码验证</title><script language="javascript">
function CheckForm()
{
if (document.form1.telephone.value=="")
{
alert("手机号不能为空!");
document.form1.telephone.focus();
return false;
}var telephone=this.form1.telephone.value;
var reg0 = /^13\d{9}$/;
var reg1 = /^15\d{9}$/;
var reg0 = telephone.match(reg0);
var reg1 = telephone.match(reg1);
if (reg0==null&®1==null)
{
alert("手机号码格式不正确!!!");
document.form1.telephone.focus();
return false;
}
return true;
}
</script>
</head><body>
<form id="form1" name="form1" method="post" onsubmit="return CheckForm()" action="http://www.bd689.com">
<input type="text" name="telephone" id="telephone" />
<input type="submit" name="button" id="button" value="提交" />
</form>
</body>
</html>- ☆☆☆技术交流群:5684178☆☆☆
- 上一篇:js 无间隙滚动代码
- 下一篇:JS的错误快速定位--JavaScript调试技巧