php 联系电话验证(手机和固话)

$tel='要验证的联系电话';

$isMob="/^1[3-5,8]{1}[0-9]{9}$/";
$isTel="/^([0-9]{3,4}-)?[0-9]{7,8}$/";
if(!preg_match($isMob,$tel) && !preg_match($isTel,$tel))
{
 exit("<script>alert('联系电话格式不正确!');window.history.go(-1);window.location.replace(document.referrer);</script>");
}

 

posted @ 2014-12-17 15:36  Bin_x  阅读(1203)  评论(0编辑  收藏  举报