how to prevent link button multiple click .before submitting first data again click 2 or 3 times same data is saving more than once in data base. i mean continues click in the sumit button data is saving repeatedly .
Loading
how to prevent link button multiple click .before submitting first data again click 2 or 3 times same data is saving more than once in data base. i mean continues click in the sumit button data is saving repeatedly .
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Naimish MakwanaRank #324 · 7.7K reputationPosted May 13, 2023, 8:38 AM EDT
One way to prevent multiple clicks on a link button or submit button is to disable the button after the first click. This can be done using JavaScript.
Here's an example of how to disable a button using jQuery:
Add the jQuery library to your HTML file. You can do this by including the following code in your head section:
Add an event listener to the button that will disable it when clicked:
$('#myButton').click(function() { $(this).prop('disabled', true); });In this example,
#myButtonis the ID of the button you want to disable.When the button is clicked, the
prop('disabled', true)function will be called, which will disable the button.Note that you'll need to include this code after the jQuery library has been loaded.
You can also add a message or spinner to indicate that the button has been clicked and the form is being processed:
$('#myButton').click(function() { $(this).prop('disabled', true); $(this).html('Processing...'); });In this example, the button text is changed to 'Processing...' when the button is clicked.
Once the form has been submitted and the data has been saved to the database, you can re-enable the button using the following code:
$('#myButton').prop('disabled', false); $('#myButton').html('Submit');Thanks
Aravind GovindarajRank #430 · 5.8K reputationPosted May 13, 2023, 3:41 PM EDT
Please use event prevent default option.
https://www.w3schools.com/jsref/event_preventdefault.asp