Input Search readOnlyProperty

Input Search 对象参考手册Input Search Object

Example

Set the search field to read-only:

document.getElementById("mySearch").readOnly = true;

Output:


Try it yourself »

Definition and Usage

The readOnly property is used to set or return whether the search field is read-only.

Read-only fields cannot be modified. However, the content of the field can be copied.

This property reflects the HTML readonly attribute.

Tip:To ensure the accuracy of form data, you can usedisabledthe property instead.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the readOnly property.


Syntax

Return the readOnly property:

searchObject.readOnly

Set the readOnly property:

searchObject.readOnly=true|false

Property Values

Value Description
true|false Describes whether the search field is read-only
  • true - The search field is read-only
  • false - Default. The search field is not read-only

Technical Details

Return Value: A Boolean value, 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;
xThe output result is:
true

Try it yourself »


Related Pages

HTML Reference Manual:HTML <input> readonly Attribute


Input Search 对象参考手册Input Search Object Other Extensions