Javascript Submit Button Locker

Here's a simple form/script that will ensure that your visitors can't hit your submit button twice.

Put the following in <head> tag:
<script language="javascript">
    var submitted = 0;
    function LockButton (form,element) {
       if ( ! submitted ) { 
           submitted = 1;
       else { alert("Form already submitted, please be patient"); }

Then, NAME your button something, and reference that name in the call to LockButton().
<input type="button" name="submitbutton" value="Test Button" onclick="LockButton(this.form,'submitbutton');" />

submit button lock button javascript Java Script

Back To Top
© 1998 - 2024
Version 7.21 | Advertise on this site