Return to Snippet

Revision: 33886
at October 14, 2010 20:20 by spraitas


Initial Code
$.fn.clearForm = function() {
// iterate each matching form
  return this.each(function() {
// iterate the elements within the form
    $(':input', this).each(function() {
      var type = this.type, tag = this.tagName.toLowerCase();
      if (type == 'text' || type == 'password' || tag == 'textarea' || type == 'hidden')
        this.value = '';
      else if (type == 'checkbox' || type == 'radio')
        this.checked = false;
      else if (tag == 'select')
        this.selectedIndex = -1;
    });
  });
};

Initial URL


Initial Description


Initial Title
Clear form data

Initial Tags
form, jquery

Initial Language
jQuery