CSS样式
使输入框和按钮变灰色,光标显示红圈斜杠样式
textarea[disabled], input[disabled]{ cursor: not-allowed; background: #F2F2F2;}
button[disabled]{ cursor: not-allowed; background-color: #d2d2d2 !important;}
JS
//禁用表单,myform为表单的ID
function makeFormDisable(myForm) {
let x = document.getElementById(myForm);
for (let i = 0; i < x.length; i++) { //遍历禁用
let element = x.elements[i];
element.disabled = "disabled";
}
//formSelects.disabled('department');//禁用layui-formSelects-master多选下拉框插件
//form.render('select'); //layui需要重新渲染下拉框
}
//取消表单的禁用状态,myform为表单的ID
function ableForm(myForm) {
let x = document.getElementById(myForm);
for (let i = 0; i < x.length; i++) {
let element = x.elements[i];
element.disabled = "";
}
//formSelects.undisabled('department');//取消layui-formSelects-master多选下拉框的禁用
//form.render('select'); //layui需要重新渲染下拉框
}