I'm trying to clear the component if the user attaches a file that is not accepted. I'm trying to do it right after it is attached. I took a look on some examples here, where some of them showed me how to do it with a reset button, that resets the whole form (something that I don't wanna do), or cloning the component (something that I tried but it is not working). I would be glad if someone could help me. Thanks in advance.
Here is an example of what I have:
$("#mycomponent").on("change", function()
{
var extension = $(this).val().split(".").pop().toString();
if((extension === "pdf") || (extension === "docx") || (extension === "doc"))
{
alert("OK");
}
else
{
alert("File extension not accepted");
var mycomponent = $("#mycomponent");
mycomponent.replaceWith(mycomponent = mycomponent.clone(true));
}
});
mycomponent.val("");?