Reset form using jQuery

One thing to be noted that pre-filled form values do not get reset using the html reset button.
In this case, javascript becomes handy. It’s again even much easier to reset using JQuery.

Here is the solution:


function resetForm(id) {
     $(':input','#'+id)
     .not(':button, :submit, :reset, :hidden')
     .val('')
     .removeAttr('checked')
     .removeAttr('selected');
}
<input type="button" onclick="resetForm('formId');" value="Reset" />

Where formId is the id of form element.

Happy client-side scripting!!