HTML input readonly Attribute
HTML <input> tag
Definition and Usage
The readonly attribute specifies that the input field is read only
(un-editable).
This attribute allows the user to highlight and copy the text inside
the input field, but not change the value.
This attribute is often used together with a JavaScript to keep the user from
editing a field before a specific task (lie clicking a button button or
selecting checkbox) is completed.
This attribute is only used if the type attribute of the input element is set
to "text" or "password".
Syntax
<input readonly="readonly" />
|
Attribute Values
Value |
Description |
readonly |
Specifies that the text or password field is read-only. |
Browser Support
The attribute is supported in all major browsers.
Example
<form action="">
<input type="text" name="demo" readonly="readonly" />
</form>
|
Try-It-Yourself Demos
input
readonly attribute example
How use the readonly attribute with the input type="text".
HTML <input> tag
|
|
|