Jesus A. Jesus A. - 4 months ago 35
jQuery Question

Clear one filed of the form after submit with jQuery

I read alot of answers but all of them talk about reset all form, that I want to do is reset only specific fields for example I have this input and this select:

<div class="col-md-12 ">
<input type="text" id="observedNEmployees" name="observedNEmployees" class="form-control">

<select class="form-control" id="severityFactorEmployee" name="severityFactorEmployee">
<option value="">Select...</option>
<option value="0"></option>
<option value="0"></option>

So for first one I try to clear when submit button is clicked liked as:


And second one:


But they didnĀ“t work

Note*: Select list need to reset to first option


To reset your form, use the following for the respective form input options.

Input Box $("#observedNEmployees").val("");

Select Box $("#severityFactorEmployee").prop('selectedIndex', 0);