js 使FORM表单的所有元素不可编辑的示例代码_javascript技巧
程序员文章站
2022-04-28 17:13:57
...
复制代码 代码如下:
//使页面不可编辑
function disableOcx() {
var form = document.forms[0];
for ( var i = 0; i var element = form.elements[i];
//部分元素可以编号 element.name 是元素自定义 name
if (element.name != "auditEntity.auditContent"
&& element.name != "auditEntity.auditAutograph"
&& element.name != "auditEntity.auditTime"
&& element.name != "auditEntity.auditState"
&& element.name != "submitBtn"
&& element.name != "reset"
&& element.name != "id"
&& element.name != "processInstanceId"
&& element.name != "updateForm") {
element.disabled = "true";
}
}
}
window.onload = disableOcx;//当页面加载的时候执行此函数
//取消不可编辑
function noDisable() {
var form = document.forms[0];
for ( var i = 0; i var element = form.elements[i];
element.disabled = false;
}
}