I am trying to reset form inputs by :
$("#form_employee_job")[0].reset();
The inputs still filled and console return undefined
What i'm missing ?
I am trying to reset form inputs by :
$("#form_employee_job")[0].reset();
The inputs still filled and console return undefined
What i'm missing ?
Have a look at this fiddle https://jsfiddle.net/yn2xeq6z/1/
If your form id isform_employee_job
then everything should work as expected. All input field of Form will be cleared.
Maybe you're missing something else, outside of the code you've posted here?
Here's a working jsfiddle that might help you on your way. This example will reset the form when you press the button.
HTML
<form id='form_employee_job'>
<input type='text'/>
</form>
<button id="btn">reset</button>
JS
$(document).ready(function() {
$("#btn").on("click", function() {
$("#form_employee_job")[0].reset();
});
});
I believe that your form might have POST data in the fields with the POST/GET request. In this case, form reset will not work.
I am not 100% sure if this is bug or the way it works.
If you have programmatically assined some values to the input, it might be able to not reset.
In order to achieve reset, you can empty the form inputs.
$(':input','#myform')
.not(':button, :submit, :reset, :hidden')
.val('')
.removeAttr('checked')
.removeAttr('selected');
Please see this post Resetting a multi-stage form with jQuery