There is a pretty similar question here but I'm doing something different. In my case when submitting the form if something fails I'm doing a history.back() to keep all values in the form, but in the case of the input files the file name remains there but there is actually no file in there. So to avoid confusion and let the user know it needs to upload the file again I want to clear the value of that element only, and another input text that has the file description.
Adding autocomplete="off"
attribute to it does the trick since prevent the browser to cache that value, but this works in Chrome
but not in IE11
.
I can also do it using JQuery like $input_file.val('').end();
but since I'm trying to do it after history.back()
is not working not sure why.
<script>
alert("Error");
window.history.back();
$('input[id="Attachment"]').val('').end();
</script>
Any other idea on how to accomplish this is welcome.