Skip to content

Instantly share code, notes, and snippets.

@guimello
Created July 14, 2010 03:15
Show Gist options
  • Save guimello/474967 to your computer and use it in GitHub Desktop.
Save guimello/474967 to your computer and use it in GitHub Desktop.
jquery reset form fields
jQuery.fn.resetForm = function()
{
$(this).find(':input').each(function(){
switch(this.type)
{
case 'password':
case 'select-multiple':
case 'select-one':
case 'text':
case 'textarea':
$(this).val('');
break;
case 'checkbox':
case 'radio':
this.checked = false;
}
});
}
@guimello
Copy link
Author

Used mainly when $('form')[0].reset() can not be applied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment