View Full Version : How do I clear a form after validation and submittal.

05-25-2004, 12:55 AM
I have a web form for viewers to complete and submt. I have written a javascript function which ensures that all fields are filled in prior to submittal. I have also written the ASP code which processes the form and writes the content to a database. So far, so good. The problem is that I have noticed that many viewers, for whatever reason, choose to hit the Submit button more than once. This, of course, results in multiple, identical fields in the database. I don't think it would do any good to write a statement at the bottom of the form instructing viewers to hit the Submit button only once. This would stop some from riding the Submit button, but
other would either not notice the statement or just ignore it.

What I am really looking for is a way to clear the form after the fields have been validated and the the form content has successfully been written to the database. I can write code which will validate the form AND clear the fields after submittal, but the problem is that the fields are cleared before
the entries can be written to the database. It seems that the best way to accomplish this is to have the form clear after a delay.

Has anyone encountered this problem in the past? Any ideas?


05-25-2004, 06:28 AM
I didn't bother to check the attachments because they are Word docs. :rolleyes:

But my suggestion to you is to check the multiple submissions in the server-side just like this forum does and/or have the primary key in the table and catch errors when executing the sql insert.

05-25-2004, 04:31 PM
Yes, that's the way to do it. Thanks for the reply.

05-25-2004, 09:04 PM
or you can set a flag after the insert.

like setting a sessionvariable when the insert is made + check at the top of the page if that sessionvariable is set before you proces the form.

05-25-2004, 09:14 PM
Thanks for the reply.