I need to add placeholder text to a search bar. I tried adding a conventional placeholder tag to the code and it doesn’t look like the text is disappearing. Is there another way to add text that disappears when users type in their query?
Could you tell me what widget you’re working with here and while you’re at it, could you send the code over so I can take a look at it?
Please insert the code within tags like this example:
Code goes here.
Thanks for your help.
I’m still not sure when/where to add the placeholder text. Here’s the code for our search input:
If you place the code in as is without the
Code goes here.
I’m not going to be able to see it correctly.
Sorry about that, Ben –
Here you go
<form action="/search-results.html" method="get"> <br> <div class="input-prepend"> <span class="add-on"><span class="icon-search">.</span></span> <input id="query" class="text span10" name="query" type="text"> <br> <div class="hmSearchOptional"> <br>
Check out this from w3School:
Would this resolve your issue?
I tried editing the code as shown below and hitting Save. The changes aren’t saving within the search box – I don’t know why I can’t add it in.
<input id="query" class="text span10" name="query" type="text" placeholder="added placeholder text here">
I just tested this out on our end and it seems to work just fine.
<form action="/search-results.html" method="get"> <br> <div class="input-prepend"> <span class="add-on"><span class="icon-search">.</span></span> <input class="text span10" id="query" name="query" placeholder="here is an example" type="text"> </div> <br> </form>
Could you confirm what version you are running on?
Not working for me – I enter the placeholder, hit Save and then it’s gone again.
We’re using version 3 or 3.1, I think. We haven’t upgraded to 3.2
Could you please confirm the version so I can test locally? We are on the latest version of 3.2 and it works well on here. If we determine it’s a regressive bug then the simplest solution would be to update to the latest version. To find your current version just take a quick look at this screenshot!
If your dashboard doesn’t look like this, then it is an older version than 3.0. In which case, click the question mark in the top right corner for the version info.
I checked the page source of your home page and saw that it said you were on version 2.11. Unless you have upgraded and not re-published your homepage I assumed this was your most current version. You are right in the fact that rich text widgets strip out the placeholder text. The HTML widget does not strip it out. Again, the best fix would be to make a back up and upgrade to the latest version which is 3.2. In our latest few releases a lot of these HTML issues have been resolved.