Home >Web Front-end >JS Tutorial >js sample code to make all elements of a FORM form uneditable_javascript tips

js sample code to make all elements of a FORM form uneditable_javascript tips

WBOY
WBOYOriginal
2016-05-16 17:19:441260browse
Copy code The code is as follows:

//Make the page uneditable
function disableOcx() {
var form = document.forms[0];
for ( var i = 0; i < form.length; i ) {
var element = form.elements[i];
// Some elements can be numbered. element.name is a custom name for the element
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;//Execute this function when the page is loaded

//Cancel uneditable
function noDisable() {
var form = document. forms[0];
for ( var i = 0; i < form.length; i ) {
var element = form.elements[i];
element.disabled = false;
}
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn