Skip to content
Advertisement

disable click button on submit

I try to update this jquery script in pure js (with bootstrap 5). The goal is to not allow someone to click twice on the payment button. Sorry I am not very strong in js. My goal is to have the same reaction that the jquery script.

I tried to follow the process on this page : Disabling a button in vanilla JavaScript and in jQuery

Thank you

My current script

JavaScript

Now the script update

JavaScript

Advertisement

Answer

setAttribute can be used in JavaScript to set the attribute of the button as disabled.

JavaScript

This can be used to disabled the button.

So when someone clicked on the submit button, you can disable the button till the data is processed.

Check the below demo code:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement