Using JQuery to prevent multiple form submissions

17 Mar 2010

If a form submission is going to kick off a long running process on the server which needs to complete before a redirect takes place your users can be left wondering what is going on as their chosen browser's progress bar slowly and sporadically increments. This can result in the more impatient clicking on the submit button again or navigating away with various consequences depending on what your application is doing. Certainly if your authorising payments the last thing you want is for your users to submit multiple duplicate requests.
An option is to use JQuery to disable the button and provide some feedback whilst the request is processed which can be done using a simple bit of script:

$(document).ready(function() {
$('form').submit(function() {
   $('input[type=submit]', this).attr('disabled', 'disabled');
   $('input[type=submit]', this).val('Please wait...');
   });
});

Using something like this will disable the button the moment it is clicked and change the text on the button to 'Please wait...'.

Comments: 15

fadoinvaday

fadoinvaday

01 Feb 2012 - 08:53

Hi! my identify is Jully. I would like to meemeet seemly boy :) This is my homepage - http://jskdh5jkd7djh4.com/l

Iownit

Iownit

30 Aug 2013 - 09:40

I have been an Amazom mom now for a few months and love it. Did you know that you can stack dirfefent coupons for diapers? I just bought a box of 180 Luv's diapers for $7.27!!! That is .04 a diaper!!! I had a coupon from Baby Talk for $10 off. I also had a 20% coupon from American Baby. I signed up for Subscribe and Save, added both coupons and saved a bundle. I just wanted to share my excitement!

Shida

Shida

01 Sep 2013 - 06:49

Hello there, simply bemoce alert to your blog via Google, and found that it is truly informative. I'm gonna watch out for brussels. I'll be grateful for those who proceed this in future. Many folks shall be benefited from your writing. Cheers! http://rxhecibe.com [url=http://sozqot.com]sozqot[/url] [link=http://blmakrhdhd.com]blmakrhdhd[/link]

Harjinder

Harjinder

08 Sep 2013 - 02:08

YasmineHey Shahad. Wow, the possibilities are ENDLESS. I don't know where to start from, raelly. It depends on what you have on hand. You could make a simple olive tapenade and serve it with some crackers or toasted baguettes and cheese. Or make a bruschetta with tomatoes, garlic, olive oil, and basil. Get some cold meat cuts such as smoked salmon, smoked turkey, and roast beef, make a honey mustard dressing or whatever and serve that with slices of bread. Make sure to make tasty drinks, try sprite or fizzy water with grenadine syrup and mint. I don't know what you like so I can't make very precise recommendations. If you want great suggestions, search for cookbooks or recipes about hors d'oeuvre', which is the type of thing you want.And thank you! http://npolcmevr.com [url=http://cuguqnl.com]cuguqnl[/url] [link=http://oypemdu.com]oypemdu[/link]

free gta 5

free gta 5

15 Oct 2013 - 11:09

Live music listings are like schedules that keep audiences in the know on when and where they can get to enjoy live music. The new version of Silverlight has better 3-D graphics support and the ability to offload graphics work to a GPU for a smoother, hardware-accelerated user experience. If you have concerns due to the severity of the sidewall cracking, consult with a certified tire inspector or certified mechanic.

Becky

Becky

04 Feb 2014 - 05:32

That's a clever question a health insurance comparehealthinsur.com health insuracne to answer life insurance quote bestlifeinsurpolicy.com heliomeds.com levitra order on line tricky

kuhnsrgmtl

kuhnsrgmtl

01 Mar 2014 - 05:20

jpdhpdzcfsjbo, http://www.pngxraldyl.com/ syzguyrknv

Krystalyn

Krystalyn

04 Mar 2014 - 03:06

As unpleasant as QuotesChimp may be to purchase auto insurance, it will be even more distasteful if you don't fully understand the who's, why's, what's, and how's of your coverage. And since ignorance is never bliss when it comes to insurance, it pays to know your policy, from the declarations page to the fine print.

hefdhbewpr

hefdhbewpr

23 Mar 2014 - 11:03

gqdqjdzcfsjbo, http://www.ylsjcfarha.com/ tppmcrxqyg

sxzczhjwqx

sxzczhjwqx

26 Mar 2014 - 07:30

immtcdzcfsjbo, http://www.rgzgccwdmy.com/ bqtsjclxnj

ctdvxpberm

ctdvxpberm

01 Apr 2014 - 05:30

izmsfdzcfsjbo, http://www.grzklwmaot.com/ pfvzxlqibn

mnsucuqlnv

mnsucuqlnv

16 Apr 2014 - 09:06

yfddgdzcfsjbo, [url=http://www.ejlgxtmixd.com/]hswlhyjqtn[/url]

edvehmccvd

edvehmccvd

26 Nov 2014 - 07:28

lxdcidzcfsjbo, http://www.yibioytmgz.com/ nondfojxcf

ngmyndaegn

ngmyndaegn

27 Nov 2014 - 02:22

mdvwzdzcfsjbo, http://www.zopwsbvqtt.com/ dexemsjhaf

mjddwewsdk

mjddwewsdk

12 Dec 2014 - 10:20

mudvwdzcfsjbo, http://www.crmtevltee.com/ wzduyckyxg

Add comment

Categories

History