WordPress.org

Forums

Contact Form 7
Display text inside input fields and hide/display them on focus and on blur (3 posts)

  1. lakthinda@gmail.com
    Member
    Posted 9 months ago #

    Hi Guys

    I wanted to have above feature in my form created using "Contact-form-7" and made a little change to the plugin core file. Hope this will help someone hence I am posting this on this forum.

    Step 1:
    Add following code between line 85-104 in "text.php" file.

    // Custom tag - onclickClear
    	if ( strstr($class_att,'onclickClear') != False )
    		$atts .= ' onfocus="if(this.value==\''.$value.'\'){this.value=\'\';}" onblur="if(this.value==\'\'){this.value=\''.$value.'\'}"';

    Step 2:
    Create a text field with class "onclickClear" and type the text you want to display inside input field in "Default value (optional)" text box.

    Result:
    The text you entered will be displayed in the form field and will be cleared on click and re-appear if you haven't entered anything.

    Enjoy!

    Kind Regards,
    Lakthinda

    http://wordpress.org/extend/plugins/contact-form-7/

  2. gbajada
    Member
    Posted 1 month ago #

    Didn't work for me.

    Should I put the code anywhere between those lines?

  3. bline007
    Member
    Posted 1 month ago #

    Ok this works, kind of. It doesn't clear the text, at least for me it didn't and if I refresh the page its just a blank field.

Reply

You must log in to post.

About this Plugin

About this Topic