js最新手机号码、电话号码正则表达式

来源:互联网 发布:淘宝装修素材刚 编辑:程序博客网 时间:2024/04/30 05:25
原文链接:http://caibaojian.com/regexp-example.html

手机号码正则表达式验证。

function checkPhone(){     var phone = document.getElementById('phone').value;    if(!(/^1[34578]\d{9}$/.test(phone))){         alert("手机号码有误,请重填");          return false;     } }

或者原文来自:http://caibaojian.com/regexp-example.html

//code from http://caibaojian.com/regexp-example.htmlfunction checkPhone(){     var phone = document.getElementById('phone').value;    if(!(/^1(3|4|5|7|8)\d{9}$/.test(phone))){         alert("手机号码有误,请重填");          return false;     } 

}

原文链接:http://caibaojian.com/regexp-example.html

固定电话号码正则表达式

 function checkTel(){ var tel = document.getElementById('tel').value;if(!/^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,14}$/.test(tel)){alert('固定电话有误,请重填');return false;}}

身份证正则:原文来自:http://caibaojian.com/regexp-example.html

//code from http://caibaojian.com/regexp-example.html//身份证正则表达式(15位)isIDCard1=/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;//身份证正则表达式(18位)isIDCard2=/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$/;身份证正则合并:(^\d{15}$)|(^\d{17}([0-9]|X)$)

0 0