Open In App

HTML DOM Input Button disabled Property

Last Updated : 02 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The Input Button disabled Property in HTML DOM is used to set or return whether the Input Button Field should be disabled or not. Disabled elements are shown in gray by default and are unusable and un-clickable.

Syntax: 

  • It returns a disabled property. 
buttonObject.disabled 
  • It is used to set the disabled Property. 
buttonObject.disabled = true|false 

Property Values: 

  • true: It specifies the button field is disabled.
  • false: It has a default value. It specifies the button field is not disabled.

Return Value: It returns a boolean value i.e. true if the Button field is disabled or false if the button field is not disabled.

Example 1: This example returns the value of the disabled property. 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Input Button disabled Property
    </title>
</head>
 
<body style="text-align:center;">
    <h1>GeeksforGeeks</h1>
 
    <h2>HTML DOM Input Button disabled Property</h2>
     
    <form id="myGeeks">
 
        <!-- Assigning button id -->
        <input type="button" id="GFG"
            onclick="myGeeks()"
            name="Geek_button"
            value="Submit">
    </form>
 
    <p id="result"></p>
 
    <script>
        function myGeeks() {
 
            // Return Input Button disabled Property
            let btnDisabled = document.getElementById("GFG").disabled;
            document.getElementById("result").innerHTML = btnDisabled;
        }
    </script>
</body>
 
</html>


Output: 

input-button-disabled

Example 2: This Example illustrates how to set the disabled Property. 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Input Button disabled Property
    </title>
</head>
 
<body style="text-align:center;">
    <h1>GeeksforGeeks</h1>
 
    <h2>HTML DOM Input Button disabled Property</h2>
 
    <form id="myGeeks">
     
        <!-- Assigning button id -->
        <input type="button" id="GFG"
            onclick="myGeeks()"
           name="Geek_button" value="Submit">
    </form>
 
    <p id="result"></p>
 
    <script>
        function myGeeks() {
 
            // Setting Input Button disabled Property
            let setBtnDisabled =
                document.getElementById("GFG").disabled = "true";
 
            document.getElementById("result").innerHTML
                = setBtnDisabled;
        }
    </script>
</body>
   
</html>


Output:

input-button-disabled-2

Supported Browsers:

  • Google Chrome
  • Internet Explorer 10.0 +
  • Firefox
  • Opera
  • Safari


Similar Reads

HTML | DOM Button disabled Property
The Button disabled property in HTML DOM is used to set or return whether a Button element would be disabled or not. A disabled element is un-clickable and unusable. It contains a boolean value. Syntax: It is used to return the button disabled property. buttonObject.disabled It is used to set the button disabled property. buttonObject.disabled = tr
2 min read
HTML | DOM Input Checkbox disabled Property
The Input Checkbox disabled property in HTML DOM is used to set or return whether the Input Checkbox field must be disabled or not. A disabled checkbox is unclickable and unusable. It is a boolean attribute and used to reflect the HTML Disabled attribute. Syntax: It returns the Input Checkbox disabled property. checkboxObject.disabled It is used to
2 min read
HTML | DOM Input Datetime disabled Property
The Input Datetime disabled property is used to set or return whether a datetime field should be disabled, or not. An element becomes unusable and un-clickable if it is disabled. Such elements are generally rendered in gray by browsers. The HTML disable attribute is reflected by the Datetime disabled property. Syntax: Returning the disabled propert
2 min read
HTML | DOM Input Date disabled Property
The Input date disabled property is used to set or return whether a date field should be disabled, or not. An element becomes unusable and un-clickable if it is disabled. Such elements are generally rendered in gray by browsers. The HTML disable attribute is reflected by the Date disabled property.Syntax: To return the disabled property: inputdateO
2 min read
HTML DOM Input DatetimeLocal disabled Property
The Input datetimeLocal disabled property in HTML DOM is used to set or return the local DateTime field which is disabled, or not. If an element is disabled then it becomes unusable and un-clickable. Such elements are generally rendered in gray by browsers. The HTML disable attribute is reflected by the DatetimeLocal disabled property.Syntax: It re
2 min read
HTML | DOM Input Email disabled Property
The Input Email disabled property in HTML DOM is used to set or return whether the Input Email field must be disabled or not. A disabled Input Email field is unclickable and unusable. It is a boolean attribute and used to reflect the HTML Disabled attribute. Syntax: It is used to return the disabled property. emailObject.disabledIt is used to set t
2 min read
HTML | DOM Input Password disabled Property
The DOM Input Password disabled Property is used to set or return the whether the Input Password Field must be disabled or not. A disabled Password Field is un-clickable and unusable. It is a boolean attribute and used to reflect the HTML Disabled attribute. It is usually rendered in grey color by default in all the Browsers. Syntax: It is used to
2 min read
HTML | DOM Input Text disabled Property
The DOM Input Text disabled Property is used to set or return the whether the Input Text Field must be disabled or not. A disabled Text Field is un-clickable and unusable. It is a boolean attribute and used to reflect the HTML Disabled attribute. It is usually rendered in grey color by default in all the Browsers.Syntax: It returns the disabled pro
2 min read
HTML | DOM Input Submit disabled Property
The Input Submit disabled property in HTML DOM is used to set or return the boolean value that represents a Submit field should be disabled or not. By default, the disabled elements are displayed in gray and are unusable and unclickable. Syntax: It returns the disabled property.submitObject.disabledIt is used to set the disabled property.submitObje
2 min read
HTML | DOM Input Reset disabled Property
The Input Reset disabled Property in HTML DOM is used to set or return a boolean value which represents a reset button field should be disabled or not. By default, the disabled elements are shown in gray and are unusable and unclickable. Syntax: It returns the disabled property.resetObject.disabledIt is used to set the disabled property.resetObject
2 min read