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.
This example first disables the button and then changes the label from "Submit" to "Please wait...".
handler first checks to see whether the form is already in the process of submitting (second click).
If so it displays an alert and disables the submit button to prevent further attempts to submit the form.
Only those with event handlers, and even then we could make do with only the FORM having an id if we wanted.
The next step is to define and assign our event handling functions.
On the second click an alert window will be displayed, while the form continues submitting (from the first click) in the background.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 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.