邮件被刷了,刷新网页照样发送
修改
var jform = $('#form'); var jsubmit = $('#submit'); var jsend = $('#send'); var countdownInterval = null; // 保存定时器 ID function startCountdown(duration) { var endTime = Date.now() + duration * 1000; // 计算结束时间戳 localStorage.setItem('sendCountdownEndTime', endTime); // 保存到 localStorage jsend.prop('disabled', true); // 禁用按钮 if (countdownInterval) { clearInterval(countdownInterval); // 清理上次倒计时 } countdownInterval = setInterval(function() { var remainingTime = Math.max(0, Math.round((endTime - Date.now())/ 1000)); // 剩余秒数 jsend.button('<?php echo lang('user_send_sucessfully');?> ' + remainingTime + ' '); if (remainingTime <= 0) { clearInterval(countdownInterval); countdownInterval = null; jsend.button('reset'); jsend.prop('disabled', false); // 启用按钮 localStorage.removeItem('sendCountdownEndTime'); // 清除 } }, 1000); } jsend.on('click', function() { jform.reset(); jsend.button('loading'); var postdata = jform.serialize(); $.xpost(jsend.attr('action'), postdata, function(code, message) { if(code == 0) { $.alert(message); $('#code').focus(); var t = 600; // 倒计时 jsend.button('<?php echo lang('user_send_sucessfully');?> 600 '); jsubmit.button('reset'); startCountdown(t); } else if(code < 0) { $.alert(message); jsend.button('reset'); } else { jform.find('[name="'+code+'"]').alert(message).focus(); jsend.button('reset'); } }); return false; }); jform.on('submit', function() { jform.reset(); jsubmit.button('loading'); var postdata = jform.serialize(); $.xpost(jform.attr('action'), postdata, function(code, message) { if(code == 0) { $.alert(message); jsubmit.button(message).delay(1000).location(xn.url('user-resetpw_complete')); } else if(xn.is_number(code)) { alert(message); jsubmit.button('reset'); } else { jform.find('[name="'+code+'"]').alert(message).focus(); jsubmit.button('reset'); } }); return false; }); $(document).ready(function() { var savedEndTime = localStorage.getItem('sendCountdownEndTime'); if (savedEndTime) { var endTime = parseInt(savedEndTime); var remainingTime = Math.max(0, Math.round((endTime - Date.now())/ 1000)); if (remainingTime > 0) { startCountdown(remainingTime) } else{ jsend.prop('disabled', false); } }else{ jsend.prop('disabled', false); } });
oliolo 修改 var jform = $('#form'); var jsubmit = $('#submit'); var jsend = $('#send'); var countdownIn ...
daxiaowang 感谢大佬,这个应该放到哪里呀
jidekang 不需要限制时间啊,不然没办法多人同时注册,可以参考https://www.xiunobbs.cn/thread-6383.htm的解决方法,增添人机验证
oliolo 那个页面需要就修改那个页面的。