1.页面示例
<html>
<head>
<script type="text/javascript">
function checkMobile(){
var checkRole=/^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\d{8}$/;
var phone=$("#phone").val();
if(!checkRole.test('19800000000')){
alert("手机号格式不正确");
}else{
alert("okokokok");
}
}
</script>
</head>
<body>
<input type="text" maxlenth="11" id="phone">
<input type="button" value ="clicks" onclick="checkMobile();">
</body>
</html>
2.java示例
public static void main(String[] args) {
Pattern pattern = Pattern.compile("^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\\d{8}$");
Boolean result = pattern.matcher("19900000000").matches();
System.out.println(result);
}