How do I get these grayed out words that appear in input texts and indicate what is this input text for? I am using JSF 2 and I need it for my login’s username and password widgets, so that the words “username” and “password” would appear inside the inputText before the user clicks in them to type his information.
If what I’m asking isn’t clear you can look for example at this site. When you hit the “ask question” button and get the question’s dialog you can see in the Title the gray words “what’s your programming question? be specific.” How is this done?
It’s called WaterMark
You need jquery watermark plugin , or use some library like primefaces that got it out of the box
here is the jquery plugin usage
jquery-watermark
just add it in ready finction of jquery:
and here an example of primefaces watermark (which use jquery plugin behind the scenes)
Watermark