By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

Styling input element text?

P: n/a
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)
Oct 4 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Ed Jay wrote:
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.
Oct 4 '06 #2

P: n/a
Dag Sunde scribed:
>Ed Jay wrote:
>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)
Oct 4 '06 #3

P: n/a
Scripsit Ed Jay:
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/

Oct 4 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.