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.
|
EXAMPLE |
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 --> <!-- Begin function reset() { function checkFields() { // field validation - else ========================================================== 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]"> <pre> 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 ] ========================================================== |