Language References
Supported only in Internet Explorer® 4 up and Netscape® 6.
Sets or retrieves whether the control may be modified by the user.
Inline |
<element READONLY ... > |
Script |
[ bRead = ] object.readOnly |
false |
The property is not set on the object. |
true |
The object is set to read-only. |
This property returns or accepts only a boolean value, meaning true if set, and false if not. The property is read/write with a default value of false.
When readOnly is set for form controls, it prohibits changes to the control: the user cannot enter or edit text in the control.
The readOnly attribute has the following effects on an element:
- Read-only elements are included in tabbing navigation.
- Read-only elements receive focus but cannot be modified by the user.
- Read-only elements may be successful, meaning the data contained in the control can be submitted with the form data set.
This is different from the disabled property. The disabled property does not allow the object to receive focus and be successful, whereas readOnly does.
How readOnly elements are rendered depends on the browser.
Note that the only way to modify dynamically the value of the readOnly attribute is through a script.
In this example, the INPUT element is read-only. Although its value will be submitted with the form and it can receive focus, changes to its content are not allowed.
<form>
<input readonly size=25
value="This control is readonly.">
</form>
HTMLAREA, INPUT type=text, INPUT type=password, TEXTAREA