判断手机号和电话号码

<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>

猜你喜欢

转载自blog.csdn.net/pmt1982/article/details/79731106