Disable input edit box?

How do you disable a control, more specifically the input box. I tried to set the disabled attribute to false and it 'looked' like it worked, it did turn the text a light gray, but you can still edit the text. I tried:

obj.setAttribute('disabled', true);

Also, with the input box, I tried to set the background color to silver (this is how we visually display disabled edit boxes) and the input box did have a silver background but the text still had the white background. Is there a single property I can change to set all of the background to one color?
Jim Hunter
October 6,
Yeah I am interested in that too...
October 19,
Is there an answer to this posted question?
November 18,
Try obj.setAttribute('disabled', 'disabled');
Rick Villela
November 18,
If readonly attribute is set, I can disable editing, but somehow once is done it can not be reversed (to enable it again - i.e. false)... Why???

obj.getContent('box/text').setAttribute('readonly', true);

December 19,

If readonly attribute is set, I can disable editing, but somehow once is done it can not be reversed (to enable it again - i.e. false)... Why???

That is because the HTML specification says that attributes such as readonly, disabled need not have a value. All you need to do is to make sure that the attribute is there. Likewise, the XHTML spec asks developers to give the same entity as its value.. that is readonly="readonly" this will not lead to the confusion that happen due to boolean values.

So the answer is to remove the property (but not set it to false)


Md. Sheriff, Drivestream
December 19,
Thanks a lot for the quick answer,
I can not get the supposed result .
Am I missing something basic ??

var SInput= new AW.UI.Input;
SInput.getContent('box/text').setAttribute('readonly', 'readonly');
var button1 = new AW.UI.Button;
button1.setControlText("Enable edit");
button1.onControlClicked = function(event){
var button2 = new AW.UI.Button;
button2.setControlText("Disable edit");
button2.onControlClicked = function(event){
SInput.getContent('box/text').setAttribute('readonly', 'readonly');
December 19,
Hi Carlos,

For a moment, i thought .getContent('box/text') returns the real DOM element refernce of the textbox.. But, it turned out to be yet another custom object reference mapping to that element.. So this should work fine (it worked for me):

button1.onControlClicked = function(event){
SInput.getContent('box/text').setAttribute('readonly', '');

Md. Sheriff, Drivestream
December 20,
Sorry guys, I am really missing something here.

Using 2.0 RC1, IE6 and examples/quickref/input.htm, if I insert the line
obj.getContent('box/text').setAttribute('readonly', true);

before the line

it doesn't seem to make any difference: I can still type stuff into the control.

Please, can anyone help?
February 2,
That attribute isn't a true/false attribute, it is a READONLY or nothing attribute. And I do not know of a way to remove the readonly setting once it's set. I think that if you use:

obj.getContent('box/text').setAttribute('readonly', 'readonly');

it will set the control to readonly and this might set it back to normal:

obj.getContent('box/text').setAttribute('readonly', 'anything');

Not sure if this will work but it should.
Jim Hunter (www.FriendsOfAW.com)
February 3,
actually, I think the real way to remove the readonly attribute is:

Jim Hunter (www.FriendsOfAW.com)
February 3,
Sorry, still stuck. Even
setAttribute('readonly', 'readonly')
does not work. Here's the example code in its entirety. This is just examples/quickref/input.htm with the one line inserted. My expectation is that when I click on the input box, then typing would not change it's contents.

I would really appreciate someone telling me what I'm doing wrong.

    <script src="../../runtime/lib/aw.js"></script>
    <link href="../../runtime/styles/xp/aw.css" rel="stylesheet"></link>
    #myInput {width: 150px; height: 25px}

<p style="font:menu">
    see page source

    var obj = new AW.UI.Input;
    obj.setId("myInput");	// necessary for CSS rules
    obj.setControlText("Some text");
    obj.getContent('box/text').setAttribute('readonly', 'readonly');  
    obj.onactivate = function() { return false; }
    obj.onkeydown = function() { return false; }
    obj.onkeypress = function() { return false; }

    obj.onControlClicked = function(event){ window.status = "Control clicked"};
    obj.onControlDoubleClicked = function(event){ window.status = "Control double clicked"};
    obj.onControlMouseOver = function(event){ window.status = "Control mouse over"};
    obj.onControlMouseOut = function(event){ window.status = "Control mouse out"};
    obj.onControlMouseDown = function(event){ window.status = "Control mouse down"};
    obj.onControlMouseUp = function(event){ window.status = "Control mouse up"};
    obj.onControlTextChanged = function(text){ window.status = "control text: " + text };


    var button = new AW.UI.Button;
    button.setControlText("Click me");

    button.onClick = function(){
    alert("input text: " + obj.getControlText());

    obj.setControlText("other text");
        alert("input text: " + obj.getControlText());

February 5,

obj.getContent('box/text').setAttribute('readonly', true); 
    obj.onControlActivated = function(){ return true; }

See related post at:
Rob Francis
February 5,
for IE, the readonly attribute is case-sensitive.

Try: obj.setAttribute('readOnly',true);

May 4,
How to use check box in a Active.Controls.Grid
August 2,
<TEXTAREA name=filedata></TEXTAREA>

worked for me in the past

August 7,
TEXTAREA name=filedata></TEXTAREA>
gulshan sharma
October 5,


In trying to crack the in-disable-able input box:

I find these don't work.

It appears as though even the getContent(...) method is not working for me. alert(obj.getContent("box/text")) is raising errors. In Mozilla: Error: uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://mywebpage.php :: prdE_edit :: line 141" data: no]. And in IE it just says "Object doesn't support this property or method".

I can work around okay though if the object is already written in the HTML then I do:

Has anyone had problems like this?
December 7,
Hmm.. appears it was happening cause I was putting the input in the innerHTML() of another object? It works okay if I call obj.toString(); before adding the input control to the parent object. (Weird.)
December 7,

Ok everyone, go to the following post:


it concerns almost every getContent("box/text").setAttribute() call you do.

(EXCERPT from Alex /javascript.forum.16359.7/input-text-and-input-password.html)

This is a bug in AW related to the caching of the html fragments. The workaround is to clear html cache manually on the control and intermediary level ('box' content).

John Mason
December 22,

This topic is archived.

See also:

Back to support forum