Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

CSS To Change Disabled Textbox Font Style?

Posted on 2000-05-16
6
1,405 Views
Last Modified: 2013-12-03
Using this small example, how do I change the color/style of the font in the textbox? (IE4+)  I want the text to look absolutely normal - no shadow, no weird colouring.

<style>
INPUT {font: 8pt;type=text}
.BLUE {background: #0469C3; border: none; color: white}
</style>
<form name=myform>
<input class=blue disabled>
</form>
0
Comment
Question by:anyanicky
6 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 2814555
blue {background: #0469C3; border:none; color:white; font-decoration:italic;font-size:11px}

etc etc....or isn;t that what you meant?
0
 
LVL 1

Author Comment

by:anyanicky
ID: 2814950
No - not that.  I know how to do that.  
Let me simplify my question...

This works
<input style="border:none;color:red"  value="this is a test">

This doesn't work
<input style="border:none;color:red" disabled value="this is a test">

I want to change the font color of the disabled textbox to look like the enabled one.
0
 
LVL 1

Accepted Solution

by:
ManoloMA earned 25 total points
ID: 2816046
Why you do not use readonly property?, then you can set the display properties as you want.

<input style="border:none;color:red" readonly value="this is a test">


Manolo
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 8

Expert Comment

by:xabi
ID: 2816077
Readonly proporty only works on IE, so if you don't want to change the color of your disabled textboxes you can use this crossbrowser code:

<input name="text1" type="text" value="Example1" onfocus="this.blur();return false;"><br>

xabi
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2816140
I guess that disabled will always override the values you assigned to it yourself. What you however could do is to ACT to be disabled.

You should then make yourself a style which looks exactly like you want it to be. Then, you store the value of the textbox. In the onChange event of the input box you then check against the stored string. If that isn't equal, then reset the value.

Shouldn't be too hard, and you have the same effect.
0
 
LVL 1

Author Comment

by:anyanicky
ID: 2816741
Manolo: Exactly what I was looking for - that works great.  Thankfully I don't have to worry about Netscape.

Xabi: That doesn't work - I can delete the contents of the field by selecting and rightclick deleting it.

CJ_S: I already know how to 'pretend' it is disabled.  The whole point of my question was to change a disabled textbox, not make something act like one.  I just thought it was very odd that I couldn't change the characteristics of a disabled textbox - apparently MS and NS have some problem with this :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question