There is a JS code that allows opening and closing access to the input field, depending on the value of the checkbox :
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> </head> <body> <form class="form-inline"> <div class="checkbox col-md-offset-5"> <label> <input id="check1" type="checkbox" onchange="checkk(this);"/> </label> </div> <div class="form-group"> <label class="sr-only" for="exampleInputEmail3">Email address</label> <input type="text" class="form-control" id="text1" disabled="true"> </div> </form> </body> </html> <script> function checkk(elem) { var value = elem.checked; if(value == true) { text1.disabled = false; } else { text1.disabled = true; text1.value = ' '; } } </script> I'm trying to do the same in my ASP.NET MVC project.
AddLearner.cshtml
... <td align="center"> <input type="checkbox" value="checked" onchange="checkk(this);" /> </td> <td align="center"> @Html.TextBoxFor(x => x.ElementPlans[i].ValueOge15, new { id = String.Format("text{0}", number++), disabled = false }) </td> </tr> } </table> } <script> function checkk(elem) { var value = elem.checked; if (value == true) { text1.disabled = false; } else { text1.disabled = true; } } </script> But my text1 field is independent of how the values ​​of the disabled attribute are spelled
disabled = false disabled = true disabled = "" @disabled = false @disabled = true или @disabled = "" always remains unavailable
Why it happens?

