bootstrapValidator 重新啟用提交按鈕的方法
bootstrapValidator 使用中,由于字段檢查等原因,致使提交按鈕失效。如何重新啟用提交按鈕呢?
下面一句代碼可以實(shí)現(xiàn)啟用提交按鈕:
$('#loginForm').bootstrapValidator('disableSubmitButtons', false);
下面看下Bootstrap中點(diǎn)擊后禁用按鈕的最佳方法
為了防止在Bootstrap中點(diǎn)擊按鈕多次提交,所以希望點(diǎn)擊按鈕后禁用按鈕。
具體實(shí)現(xiàn)方法如下:
//禁用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
將上面方法寫入點(diǎn)擊事件中即可,如:
$(".btn-check").click(function () { $('button').addClass('disabled'); // Disables visually $('button').prop('disabled', true); // Disables visually + functionally });
js按鈕點(diǎn)擊后幾秒內(nèi)不可用
function timer(time) { var btn = $("#sendButton"); btn.attr("disabled", true); //按鈕禁止點(diǎn)擊 btn.val(time <= 0 ? "發(fā)送動態(tài)密碼" : ("" + (time) + "秒后可發(fā)送")); var hander = setInterval(function() { if (time <= 0) { clearInterval(hander); //清除倒計(jì)時(shí) btn.val("發(fā)送動態(tài)密碼"); btn.attr("disabled", false); return false; }else { btn.val("" + (time--) + "秒后可發(fā)送"); } }, 1000); } //調(diào)用方法 timer(30);
以上所示是小編給大家介紹的bootstrapValidator 重新啟用提交按鈕的方法,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時(shí)回復(fù)大家的!
- jquery插件bootstrapValidator表單驗(yàn)證詳解
- 基于BootstrapValidator的Form表單驗(yàn)證(24)
- BootstrapValidator超詳細(xì)教程(推薦)
- jquery插件bootstrapValidator數(shù)據(jù)驗(yàn)證詳解
- Bootstrapvalidator校驗(yàn)、校驗(yàn)清除重置的實(shí)現(xiàn)代碼(推薦)
- BootstrapValidator不觸發(fā)校驗(yàn)的實(shí)現(xiàn)代碼
- bootstrap datepicker 與bootstrapValidator同時(shí)使用時(shí)選擇日期后無法正常觸發(fā)校驗(yàn)的解決思路
相關(guān)文章
學(xué)習(xí)掌握J(rèn)avaScript中this的使用技巧
這篇文章主要幫助大家學(xué)習(xí)并熟練掌握J(rèn)avaScript中this的使用技巧,感興趣的小伙伴們可以參考一下2016-08-08

javascript類型系統(tǒng)_正則表達(dá)式RegExp類型詳解

JavaScript使用二分查找算法在數(shù)組中查找數(shù)據(jù)的方法