How do you stop users from clicking the submit button more than once?

If there is a form submission that may take a while, many users will click the submit button multiple times. One way to prevent that from happening is to add a bit of javascript to a form button that disables the button on the first submit. For example:

<INPUT TYPE="Button"  VALUE="Submit" onClick="if(this.value == 'Submit') this.form.submit(); this.value = 'Please Wait.';this.disabled=true;">

Of course this depends on Javascript being turned on in the user's browser. Another option is to use ColdFusion's built in form handling with and . The tag has a validate option "SubmitOnce", that will prevent users from submitting the form more than once.

<cfinput type="submit" name="submit" value="Submit" validate="SubmitOnce">

This question was written by Larry C. Lyons
It was last updated on January 11, 2006.

Categories

Forms

Comments

comments powered by Disqus