I have a function that clears the text field when the user selects that text field. I would like to do the same kind of thing for the style of the text field.
here is my code:
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = “”
}
<input type=”text” name=”attorney_name” value=”enter attorney name here” style=”color:#666;” onfocus=”clearText(this);clearStyle(this);” />
For example, when the page loads, the “enter attorney name here” text will be gray, then the text field is cleared. When the user enters new text into the field, I would like the color of that text to be black.
Is there a way to create a function to change the “style” like we did for the “value”?
Thanks,
Jon