How to enable a disabled text field?

﹥>﹥吖頭↗ 提交于 2019-11-29 01:29:07

To access this element in a more standard way, use document.getElementById with setAttribute

document.getElementById("field07").setAttribute("disabled", false);

EDIT

Based on your comment, it looks like field07 is a name, not an id. As such, this should be what you want:

var allfield7s = document.getElementsByName("field07");
for (var i = 0; i < allfield7s.length; i++)
    allfield7s[i].setAttribute("disabled", false);

That is the only working solution for Me:

var allfield7s = document.getElementsByName("field07");
for (var i = 0; i < allfield7s.length; i++)
    allfield7s[i].removeAttribute("disabled");

You can enable a disabled html control with the following JavaScript code.

document.getElementById('elementId').removeAttribute('disabled');

You can also do this with jQuery:

$(function(){
    $("[name='field07']").prop("disabled", false);
});

We simply select all the elements where the name attribute is field07 (using name because you said so in the comments of @AdamRackis's answer) and set its disabled property to false.

More about prop().

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!