New Revised CSS Library Forums Web Tools
FAQs Awards Usage Terms Contact
Categories
Other Sections
Sweet Ads
Compatibility
Bookmark online:


FF1+ IE5+ Opr7+

Submit Once! Form validation

Author: Dynamic Drive

Description: 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.

Demo: (Fill out the below FAKE form, and press submit):

Name:
Description:

Directions: Developer's View

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

Select All

Step 2: Inside the form in question, add the part in red to the <FORM> tag, as follows:

<form method="POST" onSubmit="submitonce(this)">

Two simple steps for you, one giant step for form validation!