/ Published in: jQuery
Function to reset a complete form to there default value.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function resetForm(formId) { jQuery("#"+formId+" :input").each(function(i, el) { if(el.defaultValue) { jQuery(el).val(el.defaultValue) } else { jQuery(el).val("") } }) jQuery("#"+formId+" :checkbox").val([]) jQuery("#"+formId+" :radio").val([]) }