This question already has an answer here:
I would like to know how to put text in a textbox when the page loads. Example: If I have a login page, I would have 2 textboxes named "username" and "password". When the page loads I want the the textbox to load with "username" written inside, so I won't have to put a label for that outside. But when the user clicks inside textbox it should disppear. How do I do this?
...from the Stack Overflow search box.
You could also add the
onblur
event to check:if (this.value=='') this.value = 'search'
This would re-print the watermark when the user clicks outside the textbox and the field is empty.
A more modern way is to use "PlaceHolder"
There are a lot of tutorials on how to do this. Here's one walkthrough using the jQuery javascript framework.
Here's another popular blog post about it, just using regular javascript.
In laymen's terms:
The code:
See this article http://www.alistapart.com/articles/makingcompactformsmoreaccessible. Of course, if you are using jQuery, there are "Label over" plugins.
JS:
In your textbox include
onfocus="clearDefault(this)"
and set its text to "username" or "password".