简体   繁体   中英

Disable file input on form submit

I've got a form with text and file inputs that submits an ajax request. I want to temporarily disable the inputs while sending the request, and enable them again after to allow another submit.

For text inputs this works as expected:

$("form input").attr('readonly','readonly');

However, the file input still allows the user to select a new file (open the dialog). Setting the "disabled" property stops this but then the file is not submitted with the form.

  • Is this expected behavior for "readonly"?
  • Is there another solution to this?
  • Or does it really matter if the file changes after submit?

成功发送请求后,请在服务器端使用回叫数据,然后使用该数据来回叫。

$.post("YourUrl",{request: "Your Request"}) .done (function(data){\\your code here});

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