Last Updated: February 25, 2016
·
640
· u01jmg3

Reset a form

<script type="text/javascript" charset="utf-8">
function resetForm(form) {
    $(form).find('input:text, input:password, input:file, select, textarea').val('');
    $(form).find('input:radio, input:checkbox').removeAttr('checked').removeAttr('selected');
}
</script>

2 Responses
Add your response

There is also javascript's native form .reset() method:

over 1 year ago ·

You'd use my function if you already had a populated form where textboxes had values and checkboxes were checked (with the attribute set) and you wanted to reset those to be blank and unchecked.

over 1 year ago ·