A quick fix for this is to add an In this scenario the first click on the link will function normally taking the user to the target href.
At the same time it adds a new event listener to capture and disable future clicks on the same link.
The reason to use Java Script is that it disables the submit button instantaneously. I have some field validation, can I disable submit button after all validations are OK?
A quick double-click on a button or link can have unintended consequences, such as a form being submitted twice, or a script running in parallel to itself and encountering race conditions.
In this example, you can click the first button as many times as you want.
If the form is not already being submitted (first click) the handler runs the usual Java Script validation and, if successful, allows the form to be submitted.
attribute see our article on HTML5 Form Validation.
If you've been in the webmaster world for a while then you'll know that your users operate according to Sod's Law - "If anything can go wrong, it will".
This page addresses one of the less common, but still quite annoying problems, double-clickers.
A click on the submit button submits the form, but depending on your browser and connection speed the window of opportunity for a second click can vary from milliseconds to seconds.
Some modern browsers may also have taken measures to prevent duplicate submission.
The second button restores the initial state: In the default state, clicking on the Submit button will call our form validation script (see below) to make sure that all the fields have been populated.
If that is not the case then there is an alert message and the script halts.
Rather than simply disabling the button, we can also change the text so that people don't get confused.