Tool.send_code = function(obj){ ???????var isCheck = true, form = $(‘#editInfo_Form‘); ???????var mobile = form.find(‘input[name=mobile]‘).val(); ???????if(!base.isPhone(mobile)){ ???????????isCheck = false; ???????????base.showMsg("手机号格式错误"); ???????????????return; ???????} ???????if(isCheck){ ???????????var count = 60; ???????????var btn = $(obj); ???????????var resend = setInterval(function(){ ???????????????count--; ???????????????if (count > 0){ ???????????????????btn.text(count+"秒后,重新获取"); ???????????????????$(‘#send_code_btn‘).attr("disabled", true); ???????????????????$.cookie("skymsgdemo", count, {path: ‘/‘, expires: 7}); ???????????????}else { ???????????????????$(‘#send_code_btn‘).attr("disabled", false); ???????????????????clearInterval(resend); ???????????????????btn.text("重新获取验证码"); ???????????????} ???????????}, 1000); ???????????//发送验证码 ???????????$.ajax({ ???????????????????url:"/admin/index/tool", ???????????????????type:‘post‘, ???????????????????dataType:‘json‘, ???????????????????data:{‘a‘:‘editUserInfo‘,‘mobile‘:mobile,‘action‘:‘sendcode‘}, ???????????????????success:function(res) ???????????????????{ ???????????????????????base.showMsg(res.msg,2500,function(){}); ???????????????????} ???????????}) ???????}};
JS发送验证码;并设置cookie
原文地址:https://www.cnblogs.com/wanglijun/p/8716414.html