自己写的一个验证手机号码的正则表达式 验证13xx 15xx 18xx
程序员文章站
2022-07-14 20:19:25
...
正则表达式内容:1(3|5|8)[0-9]{9}$
测试页面内容:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>isMObile reg test</title>
</head>
<body>
<div id="debug"></div>
</body>
<script type="text/javascript">
var data = "15313023326";
function $(id)
{
return document.getElementById(id);
}
function isMObileFn()
{
var reg = "1(3|5|8)[0-9]{9}$";
var oReg = new RegExp(reg);
var isMObile = oReg.test(data);
$("debug").innerHTML = data + " isMObile= " + isMObile;
}
isMObileFn();
</script>
</html>