function ismobile(mobile){ return /^1([0-9]+){5,}$/g.test(mobile); } function sendmobilecode(url,obj){ if(ismobile(obj.val())){ $('#btm_sendmobilecode').attr('disabled',true); $('#btm_sendmobilecode').val("短信已发送"); $.post(url,{'mobile':obj.val()},function(data){ $('#btm_sendmobilecode').val(data); },'text'); }else{ alert("手机号码格式有误"); console.log(obj); obj.focus(); } }