Check if textbox disabled or enabled in JavaScript

Try using document.getElementById('textbox1').disabled

function CheckTextbox() {
  var id;
  for (var i = 1; 2 >= i; i++) {
    id = 'textbox' + i;
    console.log(id, 'is disabled ?', document.getElementById(id).disabled);
  }
}
<input type="text" id="textbox1" disabled="disabled">
<input type="text" id="textbox2">
<input type="button" onclick="CheckTextbox();" value='Check'>

function CheckTextbox() {
   var textbox = document.getElementById('textbox1');

   if (textbox.disabled) {
      // If disabled, do this 
       alert("disabled");
    } else {
       // Enter code here
        alert("Not disabled");
     }
}
<input type="text" id="textbox1" disabled="disabled">
<input type="button" onclick="CheckTextbox();">

Tags:

Javascript