表单常用属性
-
placeholder 背景字
-
maxlength 最大长度
-
minlength 最小长度
-
checked 单选,复选的默认选中
-
selected 下拉框默认选中
-
readonly 只读, 只能看不能改, 能够提交给服务器
-
disabled 禁用, 只能看不能改, 不能提交给服务器
-
autofocus 自动获取光标
-
autocomplete 自动提示 值: on 或 off
-
multiple 多选(文件)
-
required 不能为空
<form action="demo.php">
<input type="text" name="name" placeholder="your tel">
<br>
<input type="text" name="pwd" minlength="6" maxlength="10">
<br>
<label><input type="radio" name="sex" value="1"> 男</label>
<label><input type="radio" name="sex" value="2" checked> 女</label>
<br>
<select name="address">
<option value="1"> 地球 </option>
<option value="2"> 火星 </option>
<option value="3"> 阿联酋 </option>
<option value="4"> 泰坦星 </option>
<option value="5"> 埃塞俄比亚 </option>
<option value="6" selected> 亚欧尼亚 </option>
<option value="7"> 铁岭 </option>
<option value="8"> 四平 </option>
</select>
<br>
<input type="text" name="a" value="这是只读" readonly>
<input type="text" name="b" value="这是禁用" disabled>
<br>
<input type="text" autofocus>
<br>
<input type="text" name="tel" maxlength="11" autocomplete="Off">
<br>
<!-- 单选文件 -->
<input type="file">
<!-- 多选文件
注意:
添加属性 multiple 才能实现多选
给name值补上[], 才能真正选择多个文件
-->
<input type="file" name="photo[]" multiple>
<br>
<input type="password" name="passwd" required>
<br>
<input type="submit">
</form>