Input Search readOnly Property
Example
Set the search field to read-only:
document.getElementById("mySearch").readOnly = true;
Output result:
Try it »
Definition and Usage
The readOnly property sets or returns whether the search field is read-only.
A read-only field cannot be modified. However, its content can be copied.
This attribute reflects the HTML readonly attribute.
Tip: To ensure the accuracy of form data, you can use disabled the attribute instead.
Browser support





All major browsers support the readOnly attribute.
Syntax
Return the readOnly attribute:
searchObject
.readOnly
Set the readOnly attribute:
searchObject
.readOnly=true|false
Attribute values
| Value | Description |
|---|---|
| true|false | Describes whether the search field is read-only
|
Technical Details
| Return Value: | A Boolean value that returns true if the search field is read-only, otherwise returns false. |
|---|
More examples
Example
Check whether the search field is read-only:
var x = document.getElementById("mySearch").readOnly;
x
The output is:
true
Try it »
Related pages
HTML Reference Manual: HTML readonly attribute
Input Search Object