Only Click Submit Once

This is another hint I got from Steven Seiller in this article at Community MX.

When a programmer installs a form for visitors to send the site owner some kind of information, they only want the visitor to click the ‘Submit’ button once.  Multiple clicks of the ‘Submit’ button can cause duplication of data if being written to a data base or multiple email responses.

To deactivate the ‘Submit’ button once it’s been clicked, use this javascript at the bottom of the page just prior to the </body> tag.

<script type="text/javascript">
function disableForm(theform)
{
if (document.all || document.getElementById) {
for (i = 0; i < theform.length; i++) {
var tempobj = theform.elements[i];
if (tempobj.type.toLowerCase() == “submit” || tempobj.type.toLowerCase()
== “reset”)
tempobj.disabled = true;
}}}
</script>