1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| <script type="text/javascript"> function start_sms_button(obj){ var count = 1 ; var sum = 30; var i = setInterval(function(){ if(count > 10){ obj.attr('disabled',false); obj.val('发送验证码'); clearInterval(i); }else{ obj.val('剩余'+parseInt(sum - count)+'秒'); } count++; },1000); }
$(function(){ $('#send_sms').click(function(){ var phone_obj = $('input[name="phone"]'); var send_obj = $('input#send_sms'); var val = phone_obj.val(); if(val){ if(IsMobile(val)){ send_obj.attr('disabled',"disabled"); start_sms_button(send_obj); $.ajax({ url:'{#url_reset("index/sms")#}', data:{'mobile':val}, dataType:'json', type:'post', beforeSend:function(){ show_loading_body(); }, complete:function(){ show_loading_body(); }, success:function(data){ if(data.status!=undefined && (data.status == 'ok' || data.status == 'error')){ showMsg(data.msg); } } }); }else{ showMsg("手机号的格式错误"); } }else{ showMsg('手机号不能为空'); } }); }); </script>
|