Adding Prompt Text Inside of a Search Text Box 1

I had a client need today to make the out of the box SharePoint search box have the prompt text actually inside the box instead of before the box. I’m not sure what you call this pattern exactly but you can find it on many modern websites including on Amazon’s homepage in the A9 search box in the top right corner. The boxes I’m referring to usually have the text “Website Search” or something similar inside them and when you click the box to add your search terms, javascript usually clears them out for you.

So, I set out to make this work in the MOSS search box, and found some difficulty at first, my immediate thought was to add it with a “value” property, but SharePoint pretty much ignored that. So, I then thought I could do it in javascript, but SharePoint gives the search box a dynamic ID name like:


At the end of the day though it turns out the SharePoint already has our back when it comes to this. Apparently you can just use the QueryPromptString property of the MOSS search box. This actually takes care of all the work for you including the javascript part that clears the box when you click on it!

One comment on “Adding Prompt Text Inside of a Search Text Box

  1. Reply d3vlabs Jan 23,2009 1:13 am

    wondering if theres something similar in wss 3.0?

Leave a Reply