This article is a mirror article of machine translation, please click here to jump to the original article.

View: 11342|Reply: 0

[Jquery] Using jQuery to empty the file file field

[Copy link]
Posted on 3/14/2019 11:59:04 AM | | |
Scenario: After using validation on a file field (input type="file"), we always want to empty the values in the file field (otherwise the wrong file will still be committed)

Compatible with:

In IE, the reason for the security setting is that it is not allowed to change the value of the file field (that is, val("")) is not allowed, so obviously,

We can only change our minds, copy this input element, and then delete the original one.
When copying elements in IE, the values in them will not be copied, so the purpose of emptying the file field is achieved.
In Firefox, the values will also be copied, so we can clear it by the way to make it compatible.

Code:







Previous:JavaScript implements the transfer of image resources (base64, blob) to each other and upload them to the server
Next:The software cannot be used after recharging
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com