612-293-8629 HELLO@THEMIGHTYMO.COM

One of the most common requests I receive as a WordPress developer is to make it so that a simple form field value clears when a user clicks or focuses on a given field.  Since I use Gravity Forms for just about ever form I create, I would like to provide the following code, which was provided via the Gravity Forms forums:

 
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(".clearit input, .clearit textarea").cleardefault();
 
});

Note that you will need to add the “clearit” class to each form field via the Gravity Forms back end.

PHONE, EMAIL, TEXT

We love to communicate: phone, email, text, Facebook, Twitter, LinkedIn, you name it.

LOCATIONS

PAYMENTS ACCEPTED

Call Now

Enroll in Our Free Beginner WordPress Class by Email

Never feel powerless in WordPress again!  Become a WordPress superstar for free in only minutes a day!

Our Beginner WordPress Email Class is delivered to your inbox!

Learn More 

You Have Successfully Enrolled! Prepare For Amazing!