I need to empty all the values, all the checked boxes and all the selected items (reset the values inside ) except the inputs with type="hidden" attribute.
<form id="formname">
<input type="text" value="1232423"/>
<input type="password" value="abcdefgh"/>
<input type="file"/>
<textarea>some inputed text</textarea>
<input type="checkbox" checked="checked" />
<select>
<option>a</option>
<option selected="selected">b</option>
<option>c</option>
</select>
<input type="hidden" value="storeddata1"/>
<input type="hidden" value="storeddata2"/>
<input type="hidden" value="storeddata3"/>
</form>
Try this (https://codepen.io/AlibiGhazi/pen/XWddyPR)
$(':input','#formname')
.not(':hidden')
.val('')
.prop('checked', false)
.prop('selected', false);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="formname">
<input type="text" value="1232423"/>
<input type="password" value="abcdefgh"/>
<input type="file"/>
<textarea>some inputed text</textarea>
<input type="checkbox" checked="checked" />
<select>
<option>a</option>
<option selected="selected">b</option>
<option>c</option>
</select>
<input type="hidden" value="storeddata1"/>
<input type="hidden" value="storeddata2"/>
<input type="hidden" value="storeddata3"/>
</form>