HTML | DOM Textarea disabled Property

The DOM Textarea disabled Property is used to set or return whether the textarea element would be disabled or not. A disabled text area is un-clickable and unusable. It is a boolean attribute and used to reflect the HTML Disabled attribute.

Syntax:

  • It is used to return the disabled property.
    textareaObject.disabled
  • It is used to set the disabled property.
    textareaObject.disabled = true|false
  • Property Values:

    • true: It defines that the textarea is disabled.
    • False: It has a default value. It defines that the textarea is not disabled.

    Return Value: It returns a boolean value which represent that the textarea is disabled or not.

    Example-1: This example illustrates how to set the Textarea disabled property.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
      
    <head>
        <title>DOM textarea disabled Property</title>
    </head>
      
    <body style="text-align:center">
        <h1 style="color: green;">
          GeeksforGeeks
      </h1>
        <h2>DOM textarea disabled Property</h2>
      
        <p>This text area is non editable.</p>
      
        <!-- Assigning id to textarea. -->
        <textarea id="GFG" disabled>
            This textarea field is disabled.
        </textarea>
        <br>
        
        <button onclick="myGeeks()">Submit</button>
      
        <script>
            function myGeeks() {
                
              // Set the textarea property.
              document.getElementById(
               "GFG").disabled = false;
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before Clicking On Button:

    After Clicking On Button :

    Example-2 : This example illustrates how to return the Textarea Disabled property.

    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <!DOCTYPE html>
    <html>
      
    <head>
        <title>DOM textarea disabled Property</title>
    </head>
      
    <body style="text-align:center">
        
        <h1 style="color: green;">GeeksforGeeks</h1>
        <h2>DOM textarea disabled Property</h2>
      
        <p>This text area is non editable.</p>
      
        <!-- Assigning id to textarea. -->
        <textarea id="GFG" disabled>
            This textarea field is disabled.
        </textarea>
        <br>
        
        <button onclick="myGeeks()">Submit</button>
        
        <p id="sudo"></p>
        
        <script>
            function myGeeks() {
                //  Return Boolean value to represent textarea. 
                var x = document.getElementById("GFG").disabled;
                document.getElementById("sudo").innerHTML = x;
            }
        </script>
    </body>
      
    </html>

    chevron_right

    
    

    Output:

    Before Clicking On Button:

    After Clicking On Button:

    Supported Browsers: The browser supported by Textarea Disabled Property are listed below:

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


    My Personal Notes arrow_drop_up

    Check out this Author's contributed articles.

    If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

    Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




    Article Tags :
    Practice Tags :


    Be the First to upvote.


    Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.