Button Submit Once!

In a web application where the users are real dum the ussualy double click in buttons so the filled forms are submitting more than 1 time. Here is the script to prevent that.

[sourcecode lang=”js”]
<!–more–>
/*
Submit Once form validation-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, usage terms, and 100’s more DHTML scripts, visit http://dynamicdrive.com
*/

function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById) {
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i&lt;theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}
</script>
[/sourcecode]

[sourcecode lang=”plain”] <form method="POST" onSubmit="submitonce(this)"> [/sourcecode]

Posted in Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *