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 ) { 
           form.elements[element].disabled=true;
           submitted = 1;
           form.submit;
       }
       else { alert("Form already submitted, please be patient"); }
    }
</script>

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 psacake.com
Version 7.21 | Advertise on this site