Posted By

frankyfish on 03/17/10


Tagged

form javascript jquery


Versions (?)

jQuery Form Reset


 / Published in: jQuery
 

Function to reset a complete form to there default value.

  1. function resetForm(formId) {
  2. jQuery("#"+formId+" :input").each(function(i, el) {
  3. if(el.defaultValue) {
  4. jQuery(el).val(el.defaultValue)
  5. } else {
  6. jQuery(el).val("")
  7. }
  8. })
  9. jQuery("#"+formId+" :checkbox").val([])
  10. jQuery("#"+formId+" :radio").val([])
  11. }

Report this snippet  

You need to login to post a comment.