Skip to content

Instantly share code, notes, and snippets.

@mkelley33
Created November 28, 2012 01:18
Show Gist options
  • Save mkelley33/4158396 to your computer and use it in GitHub Desktop.
Save mkelley33/4158396 to your computer and use it in GitHub Desktop.
Clear form with JavaScript
(function($) {
$.fn.clearForm = function() {
return this.find(':input').each(function() {
switch (this.type) {
case 'password':
case 'select-multiple':
case 'select-one':
case 'text':
case 'textarea':
return $(this).val('');
case 'radio':
case 'checkbox':
return this.checked = false;
}
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment