readOnly 属性设置或返回文本域是否为只读。
textObject.readOnly=true|false
下面的例子将文本域设置为只读:
<html>
<head>
<script type="text/javascript">
function makeReadOnly()
{
document.getElementById("text1").readOnly=true
}
</script>
</head>
<body>
<form>
<input type="text" id="text1" value="Hello World!" />
<input type="button" onclick="makeReadOnly()" value="Make read-only" />
</form>
</body>
</html>