Reset or clear the form data when form is submitted by AJAX using jQuery

When a form is submitted through submit button click the form data is subsequently cleared or reset . But when we submit a form by AJAX then we have to clear the form data by picking every element and setting the value as blank. If a form contains more than 100 input fields then it is a tedious job to clear or reset the form data.

But jQuery can help you avoid this problem, itoffers many different ways to clear form data more easily. I have written some functions based upon different requirements.
You are free to use any of these.

/**
 * This function clear all input fields value including button, submit, reset, hidden fields
 * */
 
function resetForm(formid) {
 $('#' + formid + ' :input').each(function(){  
   $(this).val('').attr('checked',false).attr('selected',false);
 });
}
 
 
/**
 * This function clears all input fields value except button, submit, reset, hidden fields
 * */
 
function resetForm(formid) {
 $(':input','#'+formid) .not(':button, :submit, :reset, :hidden') .val('') .removeAttr('checked') .removeAttr('selected');
 }
 
/**
 * This function clear all input fields value except button, submit, reset, hidden fields in different way
 * */
 
function resetForm(formid)
    { 
            
            form = $('#'+formid);
            element = ['input','select','textarea'];
            for(i=0; i
150 150 Burnignorance | Where Minds Meet And Sparks Fly!