<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>正则匹配公司电话</title> </head> <body> <input id="txtLXDH" name="txtLXDH" type="text" onblur="number();" /><span>手机+057788888888+0577-88888888</span> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <script type="text/javascript"> function number() { var sNumber = document.getElementById('txtLXDH').value if (!(/^(0?1[358]\d{9})$|^((0(10|2[1-3]|[3-9]\d{2}))?[1-9]\d{6,7})$|^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/.test(sNumber))) { alert('false') return false; }else{ alert('true') return true; } }; </script> </body> </html> 提示:你可以先修改部分代码再运行。 转载请注明:有爱前端 » 正则匹配公司电话 喜欢 (0)or分享 (0)