简体   繁体   中英

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.

Let it do the submit before disabling:

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

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.

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

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

禁用提交按钮而不是表单

只禁用提交按钮怎么办?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM