999-999-9999
9999-99-9999
只能是以上3种形式符合,而且只能是数字
2 个解决方案
#1
try
^((\d{2}-\d{4})|(\d{3}-\d{3})|(\d{4}-\d{2}))-\d{4}$
^((\d{2}-\d{4})|(\d{3}-\d{3})|(\d{4}-\d{2}))-\d{4}$
#2
//校验普通电话、传真号码:可以“+”开头,除数字外,可含有“-”
function isTel(s)
{
//var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?(\d){1,12})+$/;
var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
if (!patrn.exec(s)) return false
return true
}
function isTel(s)
{
//var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?(\d){1,12})+$/;
var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
if (!patrn.exec(s)) return false
return true
}
#1
try
^((\d{2}-\d{4})|(\d{3}-\d{3})|(\d{4}-\d{2}))-\d{4}$
^((\d{2}-\d{4})|(\d{3}-\d{3})|(\d{4}-\d{2}))-\d{4}$
#2
//校验普通电话、传真号码:可以“+”开头,除数字外,可含有“-”
function isTel(s)
{
//var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?(\d){1,12})+$/;
var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
if (!patrn.exec(s)) return false
return true
}
function isTel(s)
{
//var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?(\d){1,12})+$/;
var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
if (!patrn.exec(s)) return false
return true
}