English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Method to Re-enable Submission Button in bootstrapValidator

During the use of bootstrapValidator, due to field checks and other reasons, the submit button becomes ineffective. How to re-enable the submit button?

The following line of code can enable the submit button:

Disable the submit buttons using $('#loginForm').bootstrapValidator('disableSubmitButtons', false); 

Let's take a look at the best method to disable buttons after clicking in Bootstrap.

To prevent multiple submissions when clicking buttons in Bootstrap, it is desired to disable the button after clicking.

The specific implementation method is as follows:

//Disable 'button'.
$('button').addClass('disabled'); // Visually disables
$('button').prop('disabled', true); // Visually disables + functionally
//Disable input buttons of type 'button'.
Add class 'disabled' to the input buttons of type 'button'. // Visually disables
Set the 'disabled' property of the input buttons of type 'button' to true. // Visually disables + functionally
//Disable hyperlinks
Add class 'disabled' to the anchor element. // Visually disables
$('a').prop('disabled', true); // Does nothing
$('a').attr('disabled', 'disabled'); // Visually disables

将上面方法写入点击事件中即可,如:

-check
      $('button').addClass('disabled'); // Visually disables
$('button').prop('disabled', true); // Visually disables + functionally
    });

Button is not available within a few seconds after js button click

function timer(time) {
 var btn = $("#sendButton");
 btn.attr("disabled", true); //Button is disabled
 btn.val(time <= 0 &&63; "Send dynamic password" : ("" + (time) + "Seconds until send");
 var hander = setInterval(function() {
 if (time <= 0) {
  clearInterval(hander); //Clear countdown
  btn.val("Send dynamic password");
  btn.attr("disabled", false);
  return false;
 }else {
  btn.val("" + (time--); + "Seconds until send");
 }
 }, 1000);
}
//Call method
timer();30);

The method of re-enabling the submit button of bootstrapValidator introduced above is for everyone's reference, I hope it will be helpful to everyone. If you have any questions, please leave me a message, and I will reply to everyone in time!

You May Also Like