add
onfocus="this.blur()"
to the text input
Forms on Websites
If you want to, you can make it so that if the user doesn't enter anything in the box the text re-appears after they click off it, by adding the below to the text box:
onBlur="if(this.value==''){this.value='Text';}" onFocus="if(this.value=='Text'){this.value='';}"
(Change Text to the initial text the box will be displaying).
onBlur="if(this.value==''){this.value='Text';}" onFocus="if(this.value=='Text'){this.value='';}"
(Change Text to the initial text the box will be displaying).
- Andrew Wood
- Posts: 279
- Joined: Fri 15 Aug, 2003 23.24
- Location: Location: Location
- Contact:
<pre><style type="text/css">Asa wrote:Can anyone go one stage further and have it so the text is initially a light grey but changes to black when someone clicks/starts typing in the box?
Cheers, Asa
#a {color: #999999;}
</style>
<form>
<input type="text" id="a" length="30" onBlur="this.style.color='#999999';if(this.value==''){this.value='Text';}"
onFocus="this.style.color='#000000';if(this.value=='Text'){this.value='';}"><br>
</form>
</pre>
Regards,
Andrew