Created
July 14, 2010 03:15
-
-
Save guimello/474967 to your computer and use it in GitHub Desktop.
jquery reset form fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Used mainly when $('form')[0].reset() can not be applied