Solved

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

Posted on 2006-11-23
12
4,550 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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 500 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
html input type 3 32
Javascript to allow login/password authorization 4 45
Html5 Index on a table 7 26
add image on html mail 6 19
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

810 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