Forums

Remove added file from File fied element

stojsins 18 Jan, 2019
It is possible to add remove button in or beside file field element?
If visitor add wrong file, he won't be able to remove it...
stojsins 20 Jan, 2019
Answer
I have managed to find working solution.
โ€‹
In Designer I have added in Multi field action.
First action in Multi action is File upload. Second is Custom code.
โ€‹
File upload fields has defined ID (e.g: file_1).
In Custom code I have added button element and JS code:
โ€‹
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="clear1" onclick="return false">Remove</button>
<script type="text/javascript">
var control_1 = $("#file_1");
$("#clear1").on("click", function() {
control_1.val("");
});
</script>
That's it.
โ€‹
I hope that this will help someone one day ๐Ÿ™‚
This topic is locked and no more replies can be posted.