0

We need to disable the button after a click to prevent it from being clicked again.

$('#btnSubmit').on('click',
    function(e) {
        $(this).attr('disabled', true);
    });

It works fine in Microsoft Edge. But in Chrome, the button is disabled and the form is never submitted. It seems that Chrome has an implicit event.preventDefault() when we mess up with the button.

How can we disable the button without preventing the form from being submitted?

Blaise
  • 21,314
  • 28
  • 108
  • 169
  • 1
    Have you tried the `form Submit` event instead of `button click`event ? – GGO Oct 25 '17 at 13:46
  • 1
    Possible duplicate of [Disabling a submit button when clicking on it , will prevent the form from being submitted on Google Chrome](https://stackoverflow.com/questions/20157321/disabling-a-submit-button-when-clicking-on-it-will-prevent-the-form-from-being) – Ron van der Heijden Oct 25 '17 at 14:06

1 Answers1

0

Instead of the button click, you need to disable the button after the form submit. Depending on your setup, something like this...

$('#form').on('submit',
    function(e) {
        $(#btnSubmit).attr('disabled', true);
    });
Travis Smith
  • 622
  • 5
  • 22