Input Password disabled Attribute

Definition and Usage

disabled Set or return whether the password 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 the password field:

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

Try it yourself

Example 2

Check if the password field is disabled:

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

Try it yourself

Example 3

Disable and enable the password field:

function disablePsw() {
  document.getElementById("myPsw").disabled = true;
}
function undisablePsw() {
  document.getElementById("myPsw").disabled = false;
}

Try it yourself

Syntax

Return the disabled attribute:

passwordObject.disabled

Set the disabled attribute:

passwordObject.disabled = true|false

Attribute Value

Value Description
true|false

Specify whether the password field should be disabled.

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

Technical Details

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

Browser Support

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