HTML DOM Input Text disabled Property

HTMLWeb DevelopmentFront End Technology

The HTML DOM Input Text disabled property is used for setting or returning if the text field should be disabled or not. It uses boolean values with true representing the element should be disabled and false otherwise. The disabled property is set to false by default. The disabled element is greyed out by default and is unclickable.


Following is the syntax for −

Setting the disabled property −

textObject.disabled = true|false;

Here, true=the text field is disabled and false=the text field is not disabled. It is false by default.


Let us look at an example for the Input Text disabled property −

Live Demo

<!DOCTYPE html>
<h1>Input Text disabled Property</h1>
USERNAME: <input type="text" id="TEXT1" autofocus>
<p>Disable the above text field by clicking on the DISABLE button</p>
<button type="button" onclick="disableText()">DISABLE</button>
<p id="Sample"></p>
   function disableText() {
      document.getElementById("Sample").innerHTML = "The text field is now disabled" ;


This will produce the following output −

On clicking the DISABLE button, the text field will be disabled −

Published on 19-Aug-2019 15:44:28