网络编程 
首页 > 网络编程 > 浏览文章

bootstrapValidator 重新启用提交按钮的方法

(编辑:jimmy 日期: 2026/2/26 浏览:3 次 )

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 重新启用提交按钮的方法,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!

上一篇:Bootstrap table 定制提示语的加载过程
下一篇:原生js实现轮播图的示例代码
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。