Skip to content

Instantly share code, notes, and snippets.

@tiagobbraga
Last active December 19, 2015 00:19
Show Gist options
  • Save tiagobbraga/5867438 to your computer and use it in GitHub Desktop.
Save tiagobbraga/5867438 to your computer and use it in GitHub Desktop.
resetForm = (form) ->
frm_elements = form.elements
for element in frm_elements
field_type = element.type.toLowerCase();
switch field_type
when "text", "textarea", "hidden" then element.value = ""
when "radio", "checkbox" then element.checked = false
when "select-one", "select-multi" then element.selectedIndex = -1
else element.innerHTML = "";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment