Preventing Multiple clciking of Submit button

E

Ed Richter

Have a website that uses an online form for posting to a database. One
occasional problem I have noticed is with records getting multiple posting
to the database. It probably happens less than 5% of the time. I can think
of two reasons that cause the intermittent problem.

One is people getting impatient and pressing the Submit button multiple
times. So one question is there any known ways to kind of "latch" the
submit button to prevent multiple posting? Read about something called
Ispostback that sounded like may address this issue?? It was on an ASP.Net
page so am wondering if that only works an asp.net page or will also work in
the vanilla ASP? Any other ways to prevent this?

Second possibility that is causing multiple posts is something else which I
have no idea what (since it works correctly 95+ % of time) Any other
reasons this could be occurring very randomly?
 
T

Thomas A. Rowe

Do you have a unique field (UserID, OrderNo, etc.) on the form that you can use to test against to
avoid duplicates?



--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
E

Ed Richter

Yes I do, and that certainly would work.

The problem though is some people have entered the data, then realized they
made a mistake and try to re-enter the data. I don't want them to do this
as I'd rather they either delete the original post and start over or edit
what they had entered. So I could easily check for userID, record number,
etc to test to make sure hasn't already been entered. And if it was post a
message stating that they need to go to different page to edit record. But
if a person hit the submit button multiple times would also then get this
message and that might confuse them as they got here via a different way.
They then may get amessage talking about deleting or editing record when all
they did was accidentally or on purpose hit the submit button multiple
times.

Therefore would like to separate the two methods out by eliminating posting
of record by hitting submit button more than once.
 
T

Thomas A. Rowe

You can't stop someone from hitting the submit button more than once.

As soon as the user hit the submit button, are you going to a page that processes the update, if so
then do not bring them back to the form, take them to a confirmation page.

To stop people from submitting the same data twice when they use the browser back button, you need
to test to see if the record has already been entered, and then direct the user on what to do.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
E

Ed Richter

I am taking them to a confirmation page, but what happens when someone is
accessing via dialup. They hit submit, the page sits there for a few
seconds, and they hit submit again.
 
T

Thomas A. Rowe

Do like many sites do, add a note:

"After you have clicked the submit button, it may take a few seconds to process, so please do not
click it more than once."

Also I would then do a check to make see it the record had already been added.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
R

Rick Budde

A third possibility is the user is pressing the Enter key
in the hopes that the cursor will move to the next field.
Pressing the Enter key would cause the form to Submit.
They then go back to the form to try again as they didn't
get the form filled out completely in their previous
attempt.

To avoid this, make your last required field required in
Validation.
 
E

Ed Richter

I do have a note like that, but people can't read. I had one guy submit the
same record 8 times in a row.
 
T

Thomas A. Rowe

I know what you mean...

I think you best option is to check to see if the record has been already added to the database, and
if not then run the insert statement, else display a message that the record has already been added,
etc.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
J

Jon Spivey

Another option would be to change the text on the submit button and disable
it when it's clicked, eg

<input type="submit" Value="Submit Form" onclick="this.value='Don\'t Click
Again';this.disabled=true;">
 
Top