Connecting Tech Pros Worldwide Forums | Help | Site Map

Styling input element text?

Ed Jay
Guest
 
Posts: n/a
#1: Oct 4 '06
I have a text-type form input element that I'd like to style as follows:

Before the visitor enters text, I'd like the value that is shown in the text
field to be gray, and when the visitor enters text into the filed, it is
black. Is there a way to do this?
--
Ed Jay (remove 'M' to respond by email)

Dag Sunde
Guest
 
Posts: n/a
#2: Oct 4 '06

re: Styling input element text?


Ed Jay wrote:
Quote:
I have a text-type form input element that I'd like to style as
follows:
>
Before the visitor enters text, I'd like the value that is shown in
the text field to be gray, and when the visitor enters text into the
filed, it is black. Is there a way to do this?
Can't do that with css alone, but create two classes:

..before {
color: #7f7f7f;
}

..after {
color #000000;
}

And change the element's class from 'before' to 'after' with JavaScript
in its onChange eventhandler.

--
Dag.


Ed Jay
Guest
 
Posts: n/a
#3: Oct 4 '06

re: Styling input element text?


Dag Sunde scribed:
Quote:
>Ed Jay wrote:
Quote:
>I have a text-type form input element that I'd like to style as
>follows:
>>
>Before the visitor enters text, I'd like the value that is shown in
>the text field to be gray, and when the visitor enters text into the
>filed, it is black. Is there a way to do this?
>
>Can't do that with css alone, but create two classes:
>
>.before {
color: #7f7f7f;
>}
>
>.after {
color #000000;
>}
>
>And change the element's class from 'before' to 'after' with JavaScript
>in its onChange eventhandler.
I can do that! Thanks a lot. I never thought of changing classes.
--
Ed Jay (remove 'M' to respond by email)
Jukka K. Korpela
Guest
 
Posts: n/a
#4: Oct 4 '06

re: Styling input element text?


Scripsit Ed Jay:
Quote:
Before the visitor enters text, I'd like the value that is shown in
the text field to be gray, and when the visitor enters text into the
filed, it is black.
Stop wanting that. Gray text generally means a disabled or readonly field,
i.e. a field that cannot be changed. You would just spend time and effort in
giving people _wrong_ information.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Closed Thread