Im looking to create an input text field that has greyed out text which shows what the text field is used for, this text should be then removed when a character is input
for example in facebook when you click on the search input text area, before you input any characters you will see the word “search” still displayed.
I don’t know where to start in JQuery as I have no idea what this feature is called, but below is the mark-up for my input field
HTML Markup
<div class="searchForm">
<input id="searchInput" value="Search" autocomplete="off" name="searchInput"
onkeyup="showResult(this.value)"/>
<input type="hidden" name="searchSite" value="1" style="background-color:#000;">
<input id="searchButton" type="submit" value=""/>
</div>
As the other answers suggested, I suggest using the HTML 5
placeholderattribute. For browsers that don’t support this, you can add support as follows:This code originated from here: http://www.cssnewbie.com/example/placeholder-support/
I modified it to support password fields (although they just show up as *’s) and have been using it successfully. I like it because I just use the HTML
placeholderattribute and everything works good across the board.Hope this helps!