Preventing Your Visitors From Submitting an HTML Form
More Than Once
Not all CGI programs, few
in fact, check for double form submissions, those submissions that happen
when a user clicks a form submit button more than once.
A feature missing from all click trappers I've seen, until now, is the ability
to release the trap after a certain amount of time has elapsed.
Suppose someone uses your project estimate form. When the submit button is
clicked, the click trap is set so it can't be submitted again.
However, after submitting the form, the user realizes more information should
be provided and uses the browser's "back" button to return to the form.
The user changes the information on the form and tries to submit again. And
trap. But some browsers won't.)
The trap is set. The submit button won't respond.
If the trap had been released after say, 10 seconds, the user could have
submitted the new information.
The number of seconds can be adjusted. You want it high enough to disable
the submit button for those impatient ones who click repeatedly. Yet, you
want it low enough so the lock releases in time for those who return to change
demonstration and download code. The spot where you specify the seconds is
1. When the trap is set and the user clicks the submit
2. When the trap is set and the user clicks the submit
button, a popup box with your content can pop up.
3. The first time the submit button is clicked, the
text in the submit button can change.
The number of seconds must be specified
in the script, but the list of three items above are all optional.
To display an alert box when the trap is set and the submit button is clicked,
marks, type the message you want to display in the alert box.
If you use any quotation marks in the alert box message itself, precede them
with a backslash character, like: Click the \"Ok\" button.
To cause a line break, use the backslash character and lower-case n character
pair. To cause a blank line, type the pair twice, like: "Hello!\n\nAgain!"
If you do not want to display an alert box, simply remove any message between
the quotation marks.
To display a popup box when the trap is set and the submit button is clicked,
specify the URL of the page to display within the popup. You may also specify
the pixel height and width of the popup. If you don't specify those dimensions,
Submit Button Text Change
If you want the text of the submit button to change when it's first clicked,
"Now Processing ..." for example, or "Stop! Not again!", three items of
information must be provided:
1. The form's name. This is the name="______" you have
in your FORM tag. If you don't have one, put one in.
2. The submit button's name. This is the name="______"
you have in your submit button tag. If you don't
have one, put one in. Example:
3. The new text for the submit button.
If any of the above three are missing,
Note that the new submit button text should be no longer than the original.
That's because some browsers won't enlarge the submit button even if not
all of the text will fit.
To implement this Double Click Trapper, download the working example from
http://willmaster.com/a/21t/pl.pl?art211 and then:
page source code.
to the instructions in the code.
3. Put an
attribute into the submit button tag. Example:
Then, upload the page to your server
and test it.
And may it reduce your frustration while never increasing the frustration
of the user.
About the Author:
Copyright 2003 Bontrager Connection, LLC
Bontrager Programmer/Publisher, "WillMaster Possibilities"
Are you looking for top quality scripts? Visit
and check out his highly acclaimed Master Series scripts. Some free, some
for a fee.