日期:2014-05-16  浏览次数:20464 次

js 校验电话和手机

function checkMobile(mobileControl){
??var phone = $.trim(mobileControl.val());
??if (undefined != phone && null != phone && "" != phone){
???var p1 = /^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/;
???var me = false;
???if (p1.test(phone))me=true;
???if (!me){
????mobileControl.val("");
????mobileControl.focus();
????return false;
???}
??}
??return true;
?}
?
?function checkPhone(phoneControl){
??var phone = $.trim(phoneControl.val());
??if (undefined != phone && null != phone && "" != phone){
???var regPartton=/1[3-8]+\d{9}/;
???var me = false;
???if (regPartton.test(phone))me=true;
???if (!me){
????phoneControl.val("");
????phoneControl.focus();
????return false;
???}
??}
??return true;
?}