Skip to content

Instantly share code, notes, and snippets.

@jimmycuadra
Created April 14, 2011 18:52
Show Gist options
  • Select an option

  • Save jimmycuadra/920203 to your computer and use it in GitHub Desktop.

Select an option

Save jimmycuadra/920203 to your computer and use it in GitHub Desktop.
Clear defaults before submitting
// http://jimmycuadra.com/posts/screencast-default-form-values-with-jquery
$('form').submit(function (evt) {
$(evt.currentTarget).find('input, textarea').each(function (index, element) {
var $element = $(element);
if ($element.val() == $element.data('default')) {
$element.val('');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment