Title: Search Box Default Value
Last modified: August 19, 2016

---

# Search Box Default Value

 *  [DanMichel](https://wordpress.org/support/users/danmichel/)
 * (@danmichel)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/search-box-default-value/)
 * What would I do here to give my search box a default vallue of ‘Search’ then 
   have it disappear when someone clicks it?
    `<input type="text" value="' . get_search_query().'"
   name="s" id="s" class="textbox" />`

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Gwyn Fisher](https://wordpress.org/support/users/gwynf/)
 * (@gwynf)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/search-box-default-value/#post-1788069)
 * I use this snippet:
 *     ```
       <form id="searchform" method="get" action="search.php">
       <input value="Search" name="s" id="s" onfocus="if (this.value == 'Search') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search';}" type="text">
       </form>
       ```
   
 * If you want to change the text, make sure you edit it in all 3 places
 *  Thread Starter [DanMichel](https://wordpress.org/support/users/danmichel/)
 * (@danmichel)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/search-box-default-value/#post-1788135)
 * this is what i have now
 *     ```
       $form = '<form role="search" method="get" id="searchform" action="' . home_url( '/' ) . '" >
       	<div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
       	<input type="text" value="' . get_search_query() .  ' " name="s" id="s" class="textbox" />
       	<input type="submit" id="searchsubmit" value="'. esc_attr__('') .'" class="searchsubmit" />
       	</div>
       	</form>';
       ```
   
 *  Thread Starter [DanMichel](https://wordpress.org/support/users/danmichel/)
 * (@danmichel)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/search-box-default-value/#post-1788138)
 * I’m getting an error [http://d.pr/a4nX](http://d.pr/a4nX)
 *  Thread Starter [DanMichel](https://wordpress.org/support/users/danmichel/)
 * (@danmichel)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/search-box-default-value/#post-1788143)
 * actually, this is what i have
 *     ```
       <form id="searchform" method="get" action="search.php">
       <input class="textbox" value="Search" name="s" id="s" onfocus="if (this.value == 'Search') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search';}" type="text">
       <input type="submit" id="searchsubmit" value="" class="searchsubmit" />
       </form>
       ```
   
 * but it doesn’t seem to work
 *  Thread Starter [DanMichel](https://wordpress.org/support/users/danmichel/)
 * (@danmichel)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/search-box-default-value/#post-1788159)
 * [http://pastebin.com/jDDXbg2U](http://pastebin.com/jDDXbg2U) doesnt work, and
   the sidebar doesnt load
 *  [Gwyn Fisher](https://wordpress.org/support/users/gwynf/)
 * (@gwynf)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/search-box-default-value/#post-1788168)
 *     ```
       <form id="searchform" method="get" action="search.php">
       <input class="textbox" value="Search" name="s" id="s" onfocus="if (this.value == 'Search') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search';}" type="text">
       <input type="submit" id="searchsubmit" value="" class="searchsubmit" />
       </form>
       ```
   
 * On its own that should work (though the ‘Go’ button will have no text).
 * If you’re still using the whole `$form =` … thing, then you’ll need to escape
   out all the apostrophes between `$form = '` and the closing `';` by putting a\
   immediately before each one.
 *  [whatachamp](https://wordpress.org/support/users/whatachamp/)
 * (@whatachamp)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/search-box-default-value/#post-1788395)
 * Nice one gwynf, this is working a treat.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Search Box Default Value’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 3 participants
 * Last reply from: [whatachamp](https://wordpress.org/support/users/whatachamp/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/search-box-default-value/#post-1788395)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
