js正则验证输入是否为手机号码或电话号码
首先给出原文链接:http://www.cnblogs.com/cxy521/archive/2008/06/05/1214624.html
验证手机号码正则表达式:/^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/
验证电话号码正则表达式:/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/
js 代码: var pattern=/(^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$)|(^0{0,1}1[3|4|5|6|7|8|9][0-9]{9}$)/;
if(pattern.test(val)) {
return true;
}else{
return false;
}