SUBMIT FORM ONCE

If you have forms on your site, you know they are extremely prone to abuse by users. Apart from incomplete or bogus entries, the most common offense is duplicate submissions by the same individual, caused by pressing the "Submit" button over and over and over again. Well, this DHTML script has a cure for the problem, by allowing you to disable the submit (and reset) button once it is pressed once.

 » Note that the disabling effect is applied only to IE 4+ and NS 6+ browsers. All other browsers will still be able to sneak by and submit the form (degrades well). Also, the disabled buttons can easily be resurrected by reloading the page.
 » This script was made possible by: Javascript Source !

EXAMPLE

Your Name:

Your Email:

Comments?



[ Click the submit button twice to see the script in action ]
CODE (s)

==========================================================

Step 1: Insert the below validation code into the <head> of your page:

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var submitcount=0;

function reset() {
document.emailform.name.value="";
document.emailform.email.value="";
document.emailform.comments.value="";
}

function checkFields() { // field validation -
if ( (document.emailform.name.value=="") || // checks if fields are blank.
(document.emailform.email.value=="") || // More validation scripts at
(document.emailform.comments.value=="") ) // forms.javascriptsource.com
{
alert("Please enter your name, email, and comments then re-submit this form.");
return false;
}

else
{
if (submitcount == 0)
{
submitcount++;
return true;
}
else
{
alert("This form has already been submitted. Thanks!");
return false;
}
}
}
// End -->
</script>

==========================================================

Step 2: Add the following as your HTML documents BODY tag itself:

<BODY OnLoad="reset()">

==========================================================

STEP THREE: Copy this code into the BODY of your HTML document:

<form method=post action="http://cgi.freedback.com/mail.pl" name="emailform" onSubmit="return checkFields()">

<input type=hidden name=to value="[email protected]">
<input type=hidden name=subject value="Feedback Form">

<pre>
Your Name: <input type=text name="name">
Your Email: <input type=text name="email">

Comments?

<textarea name="comments" wrap="virtual" rows="7" cols="45"></Textarea>

<input type=submit value="Submit Form!">

[ Click the submit button twice to see the script in action ]
</pre>
</form>

==========================================================

MAIN
Hosted by www.Geocities.ws