简介2018最新手机号验证正则表达式方法JS版使用方法:console.log(checkPhone('13666880092'));/***判断字符串是否符合手机号码格式*移动号段:134,135,136,137,138,139,147,150,151,152,157,158,159,170,178,182,183,184,187,188*联通号段:130,131,132,145,155,156,1
2018最新手机号验证正则表达式方法
JS版
使用方法:console.log(checkPhone('13666880092'));/***判断字符串是否符合手机号码格式*移动号段:134,135,136,137,138,139,147,150,151,152,157,158,159,170,178,182,183,184,187,188*联通号段:130,131,132,145,155,156,170,171,175,176,185,186*电信号段:133,149,153,170,173,177,180,181,189*@parammobileNums*@return待检测的字符串*/functioncheckPhone(mobileNums){vartelRegex=/^[1]((3[0-9])|(4[5,7,9])|(5[4])|(8[0-9])|(7[0,1,3,5,6,7,8]))d{8}$/;//"[1]"代表第1位为数字1,"[34587]"代表第二位可以为3、4、5、8、7中的一个,"d{9}"代表后面是可以是0~9的数字,有9位。if(telRegex.test(mobileNums)){returntrue;}else{returnfalse;}}
PHP版
$mobileNums="13666880092";var_dump(checkPhone($mobileNums));functioncheckPhone($mobileNums){if(preg_match('/^[1]((3[0-9])|(4[5,7,9])|(5[4])|(8[0-9])|(7[0,1,3,5,6,7,8]))d{8}$/',$mobileNums)){returntrue;}else{returnfalse;}}
下载链接:网站源码/小程序源码/网站模板下载