- 原型教程
- 原型 —— 主页
- 原型 —— 简要概述
- 原型 —— 有用特性
- 原型 —— 工具方法
- 原型 —— 元素对象
- 原型 —— 数字处理
- 原型 —— 字符串处理
- 原型 —— 数组处理
- 原型 —— 哈希处理
- 原型 —— 基本对象
- 原型 —— 模板
- 原型 —— 枚举
- 原型 —— 事件处理
- 原型 —— 表单管理
- 原型 —— JSON 支持
- 原型 —— AJAX 支持
- 原型 —— 表达范围
- 原型 —— 周期性执行
- 原型 —— 有用资源
- 原型 —— 快速指引
- 原型 —— 有用资源
- 原型 —— 讨论
原型 —— 表单 disable() 方法
此方法以整体方式禁用表单。表单控件将可见但不可编辑。查看以下示例。
语法
form.disable();
返回值
返回 HTMLFormElement。
示例
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
var form = $('example');
form[form.disabled ? 'enable' : 'disable']();
form.disabled = !form.disabled;
}
</script>
</head>
<body>
<p>Click the button to see the result.</p>
<br />
<form id = "example" action = "#" onsubmit = "return false">
<fieldset>
<legend>User info</legend>
<div>
<label for = "username">Username:</label>
<input name = "username" id = "username" value = "Sulien" type = "text">
</div>
<div>
<label for = "age">Age:</label>
<input name = "age" id = "age" value = "23" size = "3" type = "text">
</div>
<div>
<label for = "hobbies">Your hobbies are:</label>
<select name = "hobbies" id = "hobbies" multiple = "multiple">
<option>coding</option>
<option>swimming</option>
<option>hiking</option>
<option>drawing</option>
</select>
</div>
<div class = "buttonrow">
<button onclick = "showResult();">Toggle disabled!</button>
</div>
</fieldset>
</form>
</body>
</html>
输出
prototype_form_management.htm
广告