//校验普通电话、传真号码:可以“+”开头,除数字外,可含有“-”
function isTel(object)
{
var s =document.getElementById(object.id).value;
//电话和手机号码验证
var pattern =/^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)/;
// var pattern =/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
//var pattern =/(^[0-9]{3,4}\-[0-9]{7,8}$)|(^[0-9]{7,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/;
if(s!="")
{
if(!pattern.exec(s))
{
alert('电话号码输入有误,请输入。');
object.value="";
object.focus();
}
}
else
{
alert('电话号码不为空,请重新输入。');
}
}
网上找到的不错的方法,在此收藏了。