It's Not A Bug, It's A Feature Just another Developer weblog

12Oct/100

Prevent Multiple Submits on your forms with Jquery

Here's a simple little Jquery tidbit to prevent user form submitting the same form multiple times.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<form method="post" id="checkout" name="checkout" action="subscribe.asp"  onsubmit="return errorsOnSubmit(this);">

<input type="text" name="emailaddress" id="acceptDropShip"/>
<input type="submit" name="submit_form" value="Send" class="form_button" />
</form>
<script type="text/javascript">
var submitForm = false;
//Do some form validation and set the var submitform to true or false
if (submitForm == true) {
    $('input[type=submit]').attr('disabled', 'disabled');
    form.submit();
}else{
    return false;
}
</script>

Ohh and don't forget to include the jQuery libary...

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)


*

No trackbacks yet.