/    Sign up×
Community /Pin to ProfileBookmark

Font color of (disabled) textbox

How do I change the font color of a (disabled) textbox?

I made an input box, and another input box which I disabled.

The idea is to fill in a value in box1, press a button, and get a value after a calculation.
Only the value in the disabled box should be red instead of grey…

[code]
<form>
<input type=”text” name=”box1″>&nbsp;&nbsp;<input type=”button” name=”button1″ onClick=”minsec()” value=”press to calculate”>
<br>
<input thpe=”text” name=”box2″ disabled>
</form>

[/code]

The script is working fine, just the font color of box2 has to be changed…

In advanced thanks,

René

to post a comment
CSS

6 Comments(s)

Copy linkTweet thisAlerts:
@pyroclasmMar 08.2005 — It will work if you put:

<i>
</i>&lt;html&gt;
...

&lt;style&gt;
#box2 {
...
}
&lt;/style&gt;

...
&lt;input type="text" name="box2" [b]id="box2"[/b] disabled&gt;
...
Copy linkTweet thisAlerts:
@renevanhauthorMar 08.2005 — And what do I have to put between the <style> tags to change the color?

I'm quite new to CSS, so I need a little more...

In advanced thanks,

Regards,

René
Copy linkTweet thisAlerts:
@ffurnaiMar 08.2005 — <style>

#box2 {

color: #000000;

}

</style>
Copy linkTweet thisAlerts:
@FangMar 08.2005 — You can change the disabled field's color in FF but not in IE

An alternative is this:
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;title&gt;disabled field&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
&lt;style type="text/css"&gt;
&lt;!--
#box2 {
background:lightgrey;
color:red
}
--&gt;
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;form&gt;
&lt;input type="text" name="box1"&gt; &lt;input type="button" name="button1" onClick="minsec()" value="press to calculate"&gt;
&lt;br&gt;
&lt;input type="text" name="box2" id="box2" onfocus="this.blur();" value="none"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@renevanhauthorMar 08.2005 — Thanks to all!

I got it working, AND I got a bit more understanding of css and the stupid IE :rolleyes:

Regards,

René
Copy linkTweet thisAlerts:
@shivanayakDec 05.2006 — Is it same with IE6 and IE7, that disabled textbox font cant be changed? I have requirement to make it a generic CSS element to make it to work, new to CSS.

thank you in advance.
×

Success!

Help @renevanh spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...