js 验证手机号码和座机号码

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

你可能感兴趣的:(前端控件,工具类)