JS 验证手机号码 和 固定电话座机 正则
function checkMobile(tel){ //清空格 tel = tel.replace(/[\s\u00a0]/g, ''); //替换中文括号 tel = tel.replace('(','('); tel = tel.replace(')',')'); var phoneReg = !!tel.match(/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/); var telReg = !!tel.match(/^\((\d{3,4})\)\d{7,8}|^\d{3,4}-\d{7,8}$/); if(phoneReg || telReg){ return true; }else{ return false; } } let a = checkMobile('13221733886'); let b = checkMobile('0532-87654123'); let c = checkMobile('532-87654123'); let d = checkMobile('0532-8765412'); let e = checkMobile('(0532)87654123'); let f = checkMobile('(0532)8765412'); let g = checkMobile('(532)87654123'); let h = checkMobile('(532)8765412'); console.log('a,b,c,d,e,f,g',a,b,c,d,e,f,g);