js 验证手机号码和座机号码
程序员文章站
2022-04-04 12:54:38
...
<script type="text/javascript">
function checkTel(tel)
{
var mobile = /^1[3|5|8]\d{9}$/ , phone = /^0\d{2,3}-?\d{7,8}$/;
return mobile.test(tel) || phone.test(tel);
}
alert(checkTel('13590871234')); //true
alert(checkTel('020-12345678')); //true
alert(checkTel('1234')); //false
</script>