clears all the input fields when clicking on clear button

by santosh_patnala

JavaScript

function clearFields(form) {

    $(':input', form).each(function () {
        var type = this.type;
        var tag = this.tagName.toLowerCase();

        if (type == 'text' || type == 'password' || type == 'textarea' || type == 'email') {
            this.value = "";
        } else if (type == 'checkbox' || type == 'radio') {
            this.checked = false;
        } else if (tag == 'select') {
            this.selectedIndex = 0;
        }
    });
}