YouTip LogoYouTip

Prop Number Disabled

HTML DOM Input Number disabled Property

HTML DOM Input Number disabled Property

-- Learning is not just about technology, but also about dreams!

JavaScript Reference Manual

Overview

JavaScript Objects

Browser Objects

DOM Objects

HTML Objects

<input> - month

<input> - range

Input Number disabled Property

Input Number Object Reference Manual Input Number Object

Example

Disable the number field:

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

The output is:

Try it yourself Β»


Definition and Usage

The disabled property is used to set or return whether a number field is disabled.

An element with the disabled property is unusable and unclickable. Disabled elements are usually rendered in gray in the browser.

This property reflects the HTML disabled attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the disabled property.

Note: Internet Explorer 9 and earlier versions do not support the <input> element with the type="number" attribute.


Syntax

Get the disabled property:

numberObject.disabled 

Set the disabled property:

numberObject.disabled=true|false

Property Values

Value Description
true|false Specifies whether the number field is available.
* true - The number field is not available.
* false - Default. The number field is available.

Technical Details

Return Value: A Boolean. Returns true if the number field is not available, otherwise returns false.

More Examples

Example

Check if the number field is available:

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

The output of x will be:

true

Try it yourself Β»

Example

Disable or enable the number field:

function disableBtn() {
  document.getElementById("myNumber").disabled = true;
}

function undisableBtn() {
  document.getElementById("myNumber").disabled = false;
}

Try it yourself Β»


Related Pages

HTML Reference Manual: HTML <input> disabled attribute


Input Number Object Reference Manual Input Number Object

← Prop Number FormProp Number Autofocus β†’