WordPress.org

Forums

Gravity Forms - Placeholders add-on
Text disappears on click into the field (3 posts)

  1. Andrew Behla
    Member
    Posted 2 years ago #

    Hello,

    I'm also using your Gravity Forms - Placeholders add-on plugin. Thank you for contributing that! I'm wondering if the place holder text can go away as soon as the user put their curser in the text field, or clicks in the box.

    This is a standard functionality of most forms and it would be great if your add on could do this too. This is the site I have it on: http://www.kayaking.org

    Thanks for any help with this!

    Andrew

    http://wordpress.org/extend/plugins/gravity-forms-placeholders/

  2. steedancrowe
    Member
    Posted 2 years ago #

    behladesign and anyone else,

    I got this functionality working. Change the .each(function() in gf.placeholders.js to this:

    .each(function(){
    			var $field = $(this);
    
    			var id = this.id;
    			var $labels = $('label[for=' + id + ']').hide();
    			var label = $labels.last().text();
    
    			if (label.length > 0 && label[ label.length-1 ] == '*') {
    				label = label.substring(0, label.length-1) + ' *';
    			}
    
    			$field[0].setAttribute('placeholder', label);
    
    			$(this).focus(
    			    function(){
    			       $field[0].setAttribute('placeholder', '');
    			    });
    			$(this).blur(
    			    function(){
    			       $field[0].setAttribute('placeholder', label);
    			    });			
    
    		});
  3. zitrusman
    Member
    Posted 2 years ago #

    Thanks steedancrowe!
    That helped.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Gravity Forms - Placeholders add-on
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic