Create placeholder text for wordpress search box [closed]

I need to create a search box in my default searchform.php file that has similar behaviour as the default ability in HTML5 with the “placeholder” attribute.

This is what I have in my searchform.php at the moment:

 <input type="submit" id="searchsubmit" value="text" />
 <input placeholder="<?php _e( 'Search here..' ); ?>">

The text ‘Search here..’ appears in the input and it dissapeard when I start typeing in the input.
I need it to dissapear when I click the input.

Thx

2 Answers
2

Placeholder by itself will not disappear when you click the text field. I guess you need a bit of Javascript to achieve that.

<input type="text" onfocus="if(this.value=='<?php _e( 'Search here..' ); ?>'){this.value="";}" onblur="if(this.value==''){this.value="<?php _e( "Search here..' ); ?>';}" value="<?php _e( 'Search here..' ); ?>">

Leave a Comment