Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Text in disabled textbox should appear as normal text and not blurred text

Posted on 2006-11-23
12
Medium Priority
?
4,565 Views
Last Modified: 2008-01-09
Hi,

I have a disabled textbox in my html page and a textbox is disabled. The text is appearing blurred. I want the text in the disabled textbox should appear like a normal text which appears in normal textboxes.

Thanks in advance
0
Comment
Question by:sankarganesh
[X]
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
  • 5
  • 4
12 Comments
 
LVL 15

Expert Comment

by:bpmurray
ID: 18002400
Then don't use disabled! You probably have something like:
       <textarea id="ta1" disabled="disabled">Hello World</textarea>

Change it to use readonly instead
         <textarea id="ta2" readonly="readonly">Hello World</textarea>
0
 

Author Comment

by:sankarganesh
ID: 18003081
The requirement is I have textfield and by default the textbox is disabled and the text inside the diabled textfield is appearing blurred. I wanted to show the appearance of the text in the disabled textbox similar to the text in a non-disabled textbox. By seeing the screen one should not be able to find out if the textfield is disabled or not.
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 18003343
In general, setting readonly makes an input element appear the same as the normal input element, while disabled sets it to grey. However, you can override this quite easily using CSS. The is an example file which shows the default behaviors, and then shows the same with a simple style (yellow background, red text) added.I've shown it both for a textarea and for an ordinary input text field:

<html><head>
<style type="text/css">
.txtarea {
   background-color: yellow;
   color: red;
}
</style>
</head><body>
1. Default display settings: <br />
a. Disabled:
<textarea id="ta1a" disabled="disabled">Hello World</textarea>
&nbsp;<input id="inp1a" value="Hello World" disabled="disabled"><br />
b. Readonly:
<textarea id="ta1b" readonly="readonly">Hello World</textarea>
&nbsp;<input id="inp1b" value="Hello World" readonly="readonly"><br />
c. Normal:
<textarea id="ta1c">Hello World</textarea>
&nbsp;<input id="inp1c" value="Hello World"><br />
<br /><br />
2. Using styles to set the display: <br />
a. Disabled:
<textarea id="ta2a" disabled="disabled" class="txtarea">Hello World</textarea>
&nbsp;<input id="inp1a" value="Hello World" class="txtarea" disabled="disabled"><br />
b. Readonly:
<textarea id="ta2b" readonly="readonly" class="txtarea">Hello World</textarea>
&nbsp;<input id="inp1a" value="Hello World" readonly="readonly" class="txtarea"><br />
c. Normal:
<textarea id="ta2c" class="txtarea">Hello World</textarea>
&nbsp;<input id="inp1a" value="Hello World" class="txtarea"><br />
</body></html>
0
Flash Sale! Good things come in big bundles

Save over 50% on our fully managed dedicated server bundle for Labor Day. Plus FREE Guardian Backups, FREE Advanced DDoS Protection and FREE Plesk Onyx Web Pro Edition.

 

Author Comment

by:sankarganesh
ID: 18003669
I agree this usage of style class in html page to make life easier. What is the style class do I need to use to display the text in a disabled textbox similar to a text which is displayed in a non-disabled textbox to avoid the text appearing in greyed color?
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 18003918
Try this:
.txtarea {
   background-color: white;
   color: black;
}
0
 

Author Comment

by:sankarganesh
ID: 18003974
No. It is still appearing as blurred
0
 
LVL 15

Expert Comment

by:bpmurray
ID: 18004068
What is the HTML for that field?
0
 

Author Comment

by:sankarganesh
ID: 18004112
I tried like this
<input type="text" name="test" maxlength="100" size="55" value="" disabled="disabled" style="color: black;">
0
 
LVL 12

Expert Comment

by:jessegivy
ID: 18004421
Is this a school assignment?  Why is a perticular html attribute "required"?  Perhaps the word disabled was used not knowing that disabled is an actual attribute name.  I'm just not so sure why you're resistant to using readonly, in essence it accomplishes what you're after?  It does in essence disable the textbox but leaves the display in tact.  If readonly allows script modification of the textbox then you could write some javascript to ensure that it's truely disabled.

I notice the value is set to an empty string so what's the point of disabling?  What is it you're trying to accomplish, knowing why you want to disable the textbox might help us shed light?

~Jesse
0
 
LVL 15

Accepted Solution

by:
bpmurray earned 2000 total points
ID: 18004696
OK, it's not a text area,  but rather a text input field: your use of "textbox" had me confused. Anyway, the following will work fine:

<input type="text" name="test" maxlength="100" size="55" value="hello world" disabled="disabled" style="color: black; background-color:white;">
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

730 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