jQuery Form Reset


/ Published in: jQuery
Save to your folder(s)

Function to reset a complete form to there default value.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.