2

I want to know how to enable a disabled input field.

<input type="text" class="form" value="Text" disabled="">

I've tried to use this code via tampermonkey

var fContrl = document.getElementsByClassName("form");
for (var i = 0; i < fContrl.length; i++)
    fContrl[i].setAttribute("disabled", false);

But it doesn't work

whm11whm
  • 37
  • 1
  • 3

6 Answers6

2

You need to set the property not the attribute

// Disable
fContrl[i].disabled = true;

// Enable
fContrl[i].disabled = false;
hami
  • 1,404
  • 1
  • 12
  • 20
1

remove the disabled attribute - see demo below:

var fContrl = document.getElementsByClassName("form");
for (var i = 0; i < fContrl.length; i++)
    fContrl[i].removeAttribute("disabled");
<input type="text" class="form" value="Text" disabled="">
kukkuz
  • 39,721
  • 6
  • 52
  • 88
0

Try this way:

var fContrl = document.getElementsByClassName("form");
for (var i = 0; i < fContrl.length; i++)
    fContrl[i].disabled=false;
nacho
  • 4,905
  • 2
  • 19
  • 30
0

Check this link.

You can directly remove the attribute disabled.

fContrl[i].removeAttribute("disabled");
Rahul
  • 17,770
  • 7
  • 39
  • 58
0

Remove disable attribute from your input field.

JavaScript Code

fContrl[i].removeAttribute("disabled");
vivek s vamja
  • 973
  • 8
  • 11
0

You can achieve it by changing the line

 fContrl[i].setAttribute("disabled", false);

to

fContrl[i].disabled=false;
CCoder
  • 151
  • 10