Is there a way to write a jQuery method to delete the selected file to clear it out? How can I pass the file name to jQuery to reset the file input?
I don't want to clear all the files at once.
Here are my files:
<div class="field fieldTEXT">
<form:label path="file" cssClass="fieldLabel">
Attach Competitor:
</form:label>
<form:input path="file" type="file" cssClass="fileInput" accept="application/pdf"/> <a href="" onclick="RemoveFile();" > Remove</a>
</div>
<div class="field fieldTEXT">
<form:label path="file2" cssClass="fieldLabel">
Attach 2
</form:label>
<form:input path="file2" type="file" cssClass="fileInput"/> <a href="" onclick="RemoveFile();" > Remove</a>
</div>
<div class="field fieldTEXT">
<form:label path="file3" cssClass="fieldLabel">
Attach Additional Information:
</form:label>
<form:input path="file3" type="file" cssClass="fileInput" accept="application/pdf"/> <a href="" onclick="RemoveFile();" > Remove</a>
</div>
<div class="field fieldTEXT">
<form:label path="file4" cssClass="fieldLabel">
Attach Additional Information (If Needed):
</form:label>
<form:input path="file4" type="file" cssClass="fileInput" accept="application/pdf" /> <a href="" onclick="RemoveFile();" > Remove</a>
</div>
In my JS: How can I pass the name to my JS file and reset the selected link?
function RemoveFile(name) {
$('input[type=file]').val('');
}