Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasperf/d03996b389985781b4b7decff5403fd2 to your computer and use it in GitHub Desktop.
Save jasperf/d03996b389985781b4b7decff5403fd2 to your computer and use it in GitHub Desktop.
Clear default values in Gravity Forms and place them back in on blur if they are empty
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(".gform_wrapper input[type='text'], .gform_wrapper input[type='email'], .gform_wrapper input[type='tel'], .gform_wrapper input[type='search'], .gform_wrapper input[type='url'], .gform_wrapper input[type='number'], .gform_wrapper textarea").cleardefault();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment