• 微信号:Zh-y9213
您当前的位置:爱资源分享网 > > 网站源码 > 教程合集

DedeCMS用JS提交表单30秒才能提交第二次的实现方法

栏目:教程合集时间:2021-10-21 14:48阅读数:78人阅读

织梦网站做好了自定义表单后如何禁用提交按钮?禁用的表单样式怎么写?

如何30秒后可以提交?

经过测试找到了一个最简单的代码:


<!DOCTYPE html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>js点击按钮后,倒计时N秒后才能再次点击提交</title>
</head>
<body>
        <input type="button" id="btn" value="免费获取验证码"/>
        <script type="text/javascript">
                  var wait = 60;
                  function time(obj) {
                                            if (wait == 0) {
                                                    obj.removeAttribute("disabled");
                                                    obj.value = "免费获取验证码";
                                                    wait = 60;
                                            } else {
                                                    obj.setAttribute("disabled", true);
                                                    obj.value = "重新发送(" + wait + ")";
                                                    wait--;
                                                    setTimeout(function () {
                                                            time(obj)
                                                    },
                                                            1000)
                                            }
                                    }
                  document.getElementById("btn-form1").onclick = function () { time(this); }
        </script>
</body>
</html>
 
资源均来自第三方,谨慎下载,前往第三方网站下载

本站所有文章、数据、图片均来自互联网,一切版权均归源网站或源作者所有。

如果侵犯了你的权益请来信告知我们删除。邮箱:737597453@qq.com