JQuery check input file value to clean plugin in IE

I am currently using this jQuery to check the plugin and have a problem in IE where it removes the value of the file input fields and also validates the rest of the form.

It seems to me that this is an onfocus problem, I select a file to upload, select a different input field, and it clears the value - this only happens in the file input fields, and any other input types in the form save the fine values. I play with the plugin file, and nothing changes the fact that its cleaning the field also searched Google and could not find any help.

I tested the problem in other browsers and the value remains in place, so its just in IE.

Has anyone else used this plugin and had the same problem?

Any help would be great, thanks :)

+3
source share
1 answer

I have not worked with IE INPUT elements for IE for a while, but I think I still remember enough to be useful.

As I recall, IE cleans up any INPUT file that is not set by IE itself. I think their logic is "INPUT files should only have valid paths that the user intended, so if the INPUT file is installed by JavaScript, assume that it is malicious and cleans INPUT."

So, if your validation logic contains any type of $("INPUT[type='file']").val(something) -like, this explains the behavior you saw. Hope this helps.

+1
source

All Articles