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 is 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 text area is not disabled.
Return Value: It returns a boolean value that represents whether the text area is disabled or not.
Example-1: This example illustrates how to set the Textarea disabled property.
HTML
<!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 >
< textarea id = "GFG" disabled>
This textarea field is disabled.
</ textarea >
< br >
< button onclick = "myGeeks()" >
Submit
</ button >
< script >
function myGeeks() {
// sets the textarea disabled property.
document.getElementById(
"GFG").disabled = false;
}
</ script >
</ body >
</ html >
|
Output:
Example-2: This example illustrates how to return the Textarea Disabled property.
HTML
<!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 >
< textarea id = "GFG" disabled>This textarea
field is disabled.
</ textarea >
< br >
< button onclick = "myGeeks()" >
Submit
</ button >
< p id = "sudo" ></ p >
< script >
function myGeeks() {
// Return Textarea disabled Property
let x = document.getElementById(
"GFG").disabled;
document.getElementById(
"sudo").innerHTML = x;
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers: The browser supported by Textarea Disabled Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
16 Jun, 2023
Like Article
Save Article