Reputation: 89
So I've got a problem. I've created a text box like that:
<input type="text" id="search" name="search" class="myText" value="Search for a keyword" onclick="value=''"/>
My problem basically is that after I press the text box to write a text of my own, and then press some other place on the screen, the value I set at start (Search for a keyword) will not be displayed once again. I've tried everything. How do I make it display again once I've pressed some other place on the screen?
Upvotes: 0
Views: 45
Reputation: 3085
Get rid of the onclick="value=''
You are basically saying, empty the box whenever I click on it.
If you can use html5, you can use:
<input type="text" id="search" name="search" class="myText" placeholder="Search for a keyword" />
And you can style it as well:
<style type="text/css">
::-moz-placeholder {color:#ddd;}
::-webkit-input-placeholder {color:#ddd;}
:-ms-input-placeholder {color:#ddd;}
</style>
Upvotes: 1
Reputation: 440
You should use the placeholder attribute :
Example :
<input name="Email" type="text" id="Email" value="[email protected]" placeholder="Enter your mail" />
Upvotes: 1