User Tools

Site Tools


js:jquery_clear_a_form

Clearing a FORM

22.10.2010

function clear_form_elements(form) {
    $(form).find(':input').each(function() {
        switch(this.type) {
            case 'password':
            case 'select-multiple':
            case 'select-one':
            case 'text':
            case 'hidden':
            case 'textarea':
                $(this).val('');
                break;
            case 'checkbox':
            case 'radio':
                this.checked = false;
        }
    });
}
 
//Credit: http://www.electrictoolbox.com/jquery-clear-form///

js/jquery_clear_a_form.txt · Last modified: 2013/03/16 17:40 (external edit)