
bootstrapValidator 使用中,由于字段检查等原因,致使提交按钮失效。如何重新启用提交按钮呢?
下面一句代码可以实现启用提交按钮:
$('#loginForm').bootstrapValidator('disableSubmitButtons', false);
下面看下Bootstrap中点击后禁用按钮的最佳方法
为了防止在Bootstrap中点击按钮多次提交,所以希望点击按钮后禁用按钮。
具体实现方法如下:
//禁用button$('button').addClass('disabled'); // Disables visually$('button').prop('disabled', true); // Disables visually + functionally//禁用类型为button的input按钮$('input[type=button]').addClass('disabled'); // Disables visually$('input[type=button]').prop('disabled', true); // Disables visually + functionally//禁用超链接$('a').addClass('disabled'); // Disables visually$('a').prop('disabled', true); // Does nothing$('a').attr('disabled', 'disabled'); // Disables visually
将上面方法写入点击事件中即可,如:
$(".btn-check").click(function () { $('button').addClass('disabled'); // Disables visually$('button').prop('disabled', true); // Disables visually + functionally });
js按钮点击后几秒内不可用
function timer(time) { var btn = $("#sendButton"); btn.attr("disabled", true); //按钮禁止点击 btn.val(time <= 0 ? "发送动态密码" : ("" + (time) + "秒后可发送")); var hander = setInterval(function() { if (time <= 0) { clearInterval(hander); //清除倒计时 btn.val("发送动态密码"); btn.attr("disabled", false); return false; }else { btn.val("" + (time--) + "秒后可发送"); } }, 1000);}//调用方法timer(30);
以上所示是小编给大家介绍的bootstrapValidator 重新启用提交按钮的方法,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!