Skip to content

Instantly share code, notes, and snippets.

Created July 10, 2013 16:19
Show Gist options
  • Save anonymous/5967714 to your computer and use it in GitHub Desktop.
Save anonymous/5967714 to your computer and use it in GitHub Desktop.
A really simple function to clear default text values from forms
jQuery(document).ready(function() {
jQuery.fn.cleardefault = function() {
return this.focus(function() {
if( this.value == this.defaultValue ) {
this.value = "";
}
}).blur(function() {
if( !this.value.length ) {
this.value = this.defaultValue;
}
});
};
jQuery("input, textarea").cleardefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment