Javascript Code Prevent Multiple Form Submits

Javascript Code to Prevent Multiple Form Submissions by Creating and Toggling the Forms 'data-submitting' Attribute.

Home Short:

This method to prevent more than one submission of a form involves creating/toggling a 'data-submitting' attribute to the form. Once the submit event has occurred, the code will set this attribute to true and any further attempts to again submit the form clicking the submit button for example will be blocked because the 'data-submitting' attribute will already be set to true.

The 'data-submitting' attribute is NOT a predefined form attribute but a made up one for the purpose of keeping track of if the form has been submitted once or not. You can create any attribute name you wish after 'data-' such as 'data-giggles' or 'data-ridiculous' or anything you want but just make sure to adjust the javascript code below to account for this.

S
H
A
R
E