Recent Posts

This Post Has Been Viewed 157 Times.

Disable submit button on form submit

Posted by admin | Posted in Jquery | Posted on 07-12-2009

0

Multiple form submission is one of the issues that a webmaster face during his development.So instead of writing a hardcore code in the server side.We can just validate a multiple submission using simple client side Jquery.
Consider we have this HTML form in our code:

<form id="check" action="someUrl.php" method="get">
    <input name="username" />
    <!-- some more form fields -->
    <input id="submit" type="submit" />
</form>

Here is a jQuery code that disables submit button on form submission:

$('#check').submit(function(){
    $('input[type=submit]', this).attr('disabled', 'disabled');
});

The above jQuery code binds a submit event to our #check form, then finds its submit button and disables it.

Disable submit button on form submission for all forms on your page.

// Find ALL <form> tags on your page
$('form').submit(function(){
    // On submit disable its submit button
    $('input[type=submit]', this).attr('disabled', 'disabled');
});

Thanks HOW TO JQUERY
VN:F [1.5.7_846]
Rating: 10.0/10 (1 vote cast)
VN:F [1.5.7_846]
Rating: 0 (from 0 votes)
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • De.lirio.us
  • Xerpi

Related posts:

  1. Disable the TRACE and TRACK For More Security
  2. Simple PHP mail Script
  3. Load Another Webpage Content Using Simple Jquery
  4. View webpage source using javascript
  5. Expand and collapse toggle div using jquery
  6. Jquery Basics, How to use jquery?
  7. Caching of images using javascript image object

Write a comment

Spam Protected