I've been trying to make a default value in a text box go away when clicked.
The general consensus on this forum and on the rest of the internet seems to be that this code:
if (field.defaultValue == field.value) field.value = ''
else if (field.value == '') field.value = field.defaultValue;
<input name="emailaddress" type="text" id="email_box" value="Enter Your Email Address" onFocus="clearText(this)" onBlur="clearText(this)">
works pretty well. But I wonder how I can add a color change to this function. They default value "enter email address here" would be in grey, but when the user begins to type, it would be black. then deleted what'd been typed, back to grey.
document.getElementById(email_box).style.color='#000000'; .....is that too naïve..? It didn't work no matter where I put it. And dreamweaver didn't like it when I tried to copy the syntax of the first function, but make it change colors instead. It furthermore hated me trying to assign two different functions to the onClick event.
It also didn't like at all when I tried to apply two classes to the same object...
All in all, it's been pretty disagreeable today.
Thank you in advance to anyone who can help me out!