There is a feedback form, there are all sorts of input fields and another file is attached. So, after submitting the form, if you click on the "attach file" link again, the previously selected file is highlighted. But if the page is updated, then the choice is new. And if the form is re-sent without attaching the file, it is attached again. How after resetting the form to reset the value of the attached file?

 $('#form_values_file').val(''); 

Does not help

    3 answers 3

    https://css-tricks.com/snippets/jquery/clear-a-file-input/

    Jquery

     var input = $("#control"); function something_happens() { input.replaceWith(input.val('').clone(true)); }; 

    Call a function on form submission and on $( document ).ready()

      Try this:

       $('#form_values_file').trigger( 'reset' ); 

        You can reset the entire form by accessing it by its id . Example for the form with id "your_form_id" :

         $('#your_form_id')[0].reset();