Created
February 11, 2013 18:41
-
-
Save thePunderWoman/4756545 to your computer and use it in GitHub Desktop.
Jquery Clear Form
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
clearForm = function (idstr) { | |
var fields = $(idstr).find("input:not([type=hidden]):not([type=submit]):not([type=reset])"); | |
$(fields).each(function (i, obj) { | |
if ($(obj).attr('type') == 'checkbox') { | |
$(obj).attr('checked', $(obj).data('default') == 'checked') | |
} else { | |
$(obj).attr('value', $(obj).data('default')); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment