I am trying to use jQuery to do a simple thing: clear the input fields of a group of input field within a div whenever the form loads, or if the user changes a picklist; but
This function is used to clear all the elements in the form including radio button, check-box, select, multiple select, password, text, textarea, file.
function clear_form_elements(class_name) {
jQuery("."+class_name).find(':input').each(function() {
switch(this.type) {
case 'password':
case 'text':
case 'textarea':
case 'file':
case 'select-one':
case 'select-multiple':
case 'date':
case 'number':
case 'tel':
case 'email':
jQuery(this).val('');
break;
case 'checkbox':
case 'radio':
this.checked = false;
break;
}
});
}