Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Input Checkbox disabled Property
The HTML DOM Input Checkbox disabled property sets/returns whether Input Checkbox is to be enabled or disabled.
Syntax
Following is the syntax −
- Returning boolean value − true/false
inputCheckboxObject.disabled
- Setting disabled to booleanValue
inputCheckboxObject.disabled = booleanValue
Boolean Values
Here, “booleanValue” can be the following −
| booleanValue | Details |
|---|---|
| true | It defines that the checkbox is disabled. |
| false | It defines that the checkbox is not disabled and it is also the default value. |
Example
Let us see an example of Input Checkbox disabled property −
<!DOCTYPE html>
<html>
<head>
<title>Student Details</title>
</head>
<body>
<form>
<div>
<input id="fullname" placeholder="eg: John Doe" type="text" name="fullname">
</div>
<div>
Biology: <input class="category" type="checkbox" value="Biology" name="subject" disabled>
Mathematics: <input class="category" type="checkbox" value="Mathematics" name="subject" disabled>
Physics: <input class="category" type="checkbox" value="Physics" name="subject" disabled>
Psychology: <input class="category" type="checkbox" value="Psychology" name="subject" disabled>
</div>
</form>
<button onclick="enableCheckboxes()">Enable Subjects</button>
<script>
function enableCheckboxes(){
var enableCheckboxes = document.getElementsByClassName("category");
for (var i = 0; i < enableCheckboxes.length; i++) {
enableCheckboxes[i].disabled = false;
}
}
</script>
</body>
</html>
Output
This will produce the following output −
Before clicking ‘Enable Subjects’ button −

After clicking ‘Enable Subjects’ button −

Advertisements