var re=new RegExp(/^(^(0\d{2})-(\d{8})$)|(^(0\d{3})-(\d{7})$)|(^(0\d{2})-(\d{7})$)|(^(0\d{3})-(\d{8})$)$/);
if (!document.myform.phone.value.match(re))
{
alert("电话号码格式应该如:020-87337281或0731-4820128,请重新输入!");
document.myform.phone.focus();
return false;
}
其中myform为表单名字,而phone为电话号码的name值,js采取正则表达式