截止2015年6月底,现有手机号有以下几种:
A.电信号段:133/153/180/181/189/177;
B.联通号段:130/131/132/155/156/185/186/145/176;
C.移动号段:134/135/136/137/138/139/150/151/152/157/158/159/182/183/184/187/188/147/178。
正则表达式为:
/^((1[3,8][0-9])|(15[0,1,2,3,5,6,7,8,9])|(14[5,7])|(17[0,6,7,8]))\d{8}$/
示例代码如下:
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> </head> <body> <input type="text" id="tel"/> <button onclick="javascript: checkTel();">校验</button> <script> function checkTel(){ var tel = document.getElementById(‘tel‘).value; var regexp = /^((1[3,8][0-9])|(15[0,1,2,3,5,6,7,8,9])|(14[5,7])|(17[0,6,7,8]))\d{8}$/; if(!regexp.test(tel)){ alert("您输入的手机号格式不正确,请重新输入"); } } </script> </body> </html>
时间: 2024-10-19 04:39:57