禁用的界面的3中方式:
1.disabled 属性 文字会变成灰色,不可编辑。
2.readonly 属性 文字不会变色,也是不可编辑的
3.οnfοcus=this.blur() 当鼠标放不上就离开焦点
代码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript">
var saveday = prompt("请输入当前月份信息","");
if (saveday.length >0) {
alert("大于0");
}
//if(/^[0-9]+$/.test(saveday)){}// 只能输入数字
//只能输入中文英文数字
if(/^[\a-\z\A-\Z0-9\u4E00-\u9FA5]+$/.test(saveday)){}
else{
alert("不是中文、英文、数字");
}
</script>
</head>
<body>
<input type="text" name="input1" value="中国" disabled="true">
<input type="text" name="input1" value="中国" onfocus=this.blur()>
<input type="text" name="input1" value="中国" readonly>
<input type="text" name="input1" value="中国" readonly="true">
</body>
</html>
如果通过js或者jquery进行设置的话代码如下:
$("#id").attr("readonly","readonly"); //通过id 未测试
$("input[name='AnTaiPersonnelApprovalProcess.HRAccount']").val(data.OK);//通过name 赋值
$("input[name='AnTaiPersonnelApprovalProcess.HRAccount']").attr('readonly',true);//通过name 进行设置只读属性。
//input 的内容
<input name="AnTaiPersonnelApprovalProcess.HRAccount" id="AnTaiPersonnelApprovalProcess.HRAccount" type="text" value="文本框" style="border-collapse: collapse; margin-bottom: 0px;" type1="flow_text" valuetype="0" defaultvalue="" align="left"/>