Clear Text Box When Clicking on It
If you have a text box on your webpage (eg – a search form) with text in it (eg – “Search…”), it adds an extra level of convenience for your user if the text box clears when the user clicks inside the box. This is achieved with some simple javascript:
<input onclick="this.value='';" name="Search" type="text" value="Search..." />
The crucial part is onclick=”this.value=”;” – whenever the text box is clicked on, it sets the text box’s value to empty.
If you want, you could have the box automatically refilled with the same text or different text with this simple addition to the above code.
onblur="if (this.value == '') {this.value = 'your email';
You may have already noticed the Search form and Email Subscription form are configured this way. Try it out.


(2 votes, average: 4.00 out of 5)

I’ve always wondered how to do that, lol…thanks!
you’re welcome!
little things like this sometimes make users experience alot funner.
how do you do the on click effect for a one time deal. If you have not noticed if a person clicks on the text box area again after entering information it is erased. I just want it on the initial click that’s all???
then leave the following part out.
onblur=”if (this.value == ”) {this.value = ‘your email’;