Martin Brown
Martin Brown

Reputation: 25329

Disabled form not submitting its fields

I am trying to disable the form on my site when the user click the submit button to stop duplicate submissions. Due to there being an input type file on the form the upload can take a while. So far I have tried this

$("#uploadForm").submit(function () {
    $(":input", this).attr('disabled', 'disabled');
});

The trouble is that this stops the form sending any data to the web server. Is there some way to disable the form and still have it post the data.

Upvotes: 1

Views: 272

Answers (5)

Brother Erryn
Brother Erryn

Reputation: 841

Let it do the submit before disabling:

$("#uploadForm").submit(function () {
    setTimeout(function(){$("#uploadForm :input").attr('disabled','disabled');}, 10);
    return true;
});

Upvotes: 3

Avien
Avien

Reputation: 1260

how about using a progress bar when submit is clicked..

http://plugins.jquery.com/project/loading

Upvotes: 1

buddhabrot
buddhabrot

Reputation: 1586

I wouldn't disable the input button, this is confusing for the user. I would just overlay the form with a "Uploading.." message. See jQuery BlockUI plugin.

Upvotes: 1

dl__
dl__

Reputation: 4610

What about just disabling the submit button?

Upvotes: 0

cristian
cristian

Reputation: 8744

Disable the submit button not the form

Upvotes: 0

Related Questions