创建表单<form></form>

表单form
- action 提交地址
- 各种控件:
1. 文本框 type=text name value maxLength readonly placeholder
2. 密码框 password name
3. 单选 radio name value checked id label
4. 多选 checkbox name value checked id label
5. 日期 date name
6. 文件 file name
7. 隐藏域 hidden name value
8. 下拉选 select:name option:value selected
9. 文本域 textarea: name palceholder cols rows

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="http://www.baidu.cn">
<!-- 所有控件必须添加name属性不然不会提交数据
	maxlength:最大字符长度
	value:设置默认值
	placeholder:占位文本
	readonly 只读
	 -->
	用户名:<input type="text" name="username"
	maxlength="5" value="Tom" 
	placeholder="请输入用户名" 
	readonly="readonly"><br>
	密码:<input type="password" name="password"
		placeholder="请输入密码"><br>
	性别:<input type="radio" name="gender"
	 value="nan" id="r1"><label for="r1">男</label>
	<input type="radio" name="gender" checked="checked" 
	value="nv" id="r2"><label for="r2">女</label><br>
	爱好:<input type="checkbox" 
			name="hobby" value="code"
				 id="c1"><label for="c1">游泳</label>
	<input type="checkbox" 
		name="hobby" value="lq"
			id="c2"><label for="c2">打篮球</label>
	<input type="checkbox" 
		name="hobby" value="dx" checked="checked">踢足球
	<input type="checkbox" 
		name="hobby" value="wz">乒乓球<br>
	生日:<input type="date" name="birthday"><br>	 
	生活照: <input type="file" name="pic"><br>
	<!-- 隐藏域  当需要给服务器提交一个数据
			但是这个数据不希望用户看的时候使用隐藏域-->
	<input type="hidden" name="xxx" value="yyy">
	所在城市:<select name="city">
		<option>请选择</option>
		<option value="bj">云南</option> 
		<option value="sh" selected="selected">新疆</option>
		<option value="gz">蒙古</option>
	</select><br>
	自我介绍:<textarea rows="3" cols="20" 
		placeholder="说点儿什么。。。"
		name="des"></textarea><br>
	<input type="submit" value="注册">
	<input type="reset" >
	<input type="button" value="按钮">  
	
	
</form>
</body>
</html>

  

Insert title here

用户名:
密码:
性别:
爱好: 踢足球 乒乓球
生日:
生活照:
所在城市:
自我介绍:
原文地址:https://www.cnblogs.com/xingsir/p/12749930.html