SoFunction
Updated on 2025-04-10

Using javascript to disable all text boxes, drop-down menus, and multi-line text fields on web pages

The principle is to loop to get the controls on the web page and then set the disabled property to true.

The code is as follows:

Copy the codeThe code is as follows:

<script type="text/javascript">
    var nodeList = ("input");
    for (var i = 0; i < ; i++) {
        nodeList[i].disabled = true;
    }
    nodeList = ("select");
    for (var i = 0; i < ; i++) {
        nodeList[i].disabled = true;
    }
    nodeList = ("textarea");
    for (var i = 0; i < ; i++) {
        nodeList[i].disabled = true;
    }
</script>

Here are the types of these controls:

You can get it through ("controlName")[0].().

Depending on the control, there are the following types:
"text"
"textarea"
"select-one"
"select-multiple"
"radio"
"checkbox"