Input Search disabled attribute

Definition and Usage

disabled Set or return whether the search field should be disabled.

Disabled elements are not available and cannot be clicked. By default, disabled elements are usually displayed in gray in the browser.

This property reflects the HTML disabled attribute.

See also:

HTML Reference Manual:HTML <input> disabled Attribute

Example

Example 1

Disable search field:

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

Try it yourself

Example 2

Check if the search field is disabled:

var x = document.getElementById("mySearch").disabled;

Try it yourself

Example 3

Enable and disable search field:

function disableBtn() {
  document.getElementById("mySearch").disabled = true;
}
function undisableBtn() {
  document.getElementById("mySearch").disabled = false;
}

Try it yourself

Syntax

Return disabled attribute:

searchObject.disabled

Set disabled attribute:

searchObject.disabled = true|false

Attribute Value

Value Description
true|false

Specify whether the search field should be disabled.

  • true - The search field is disabled
  • false - Default. The search field is not disabled

Technical Details

Return value: Boolean value, if the search field is disabled, it returns true; otherwise return false.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support