HTML -> 表单初级验证
- placeholder 提示信息
- required:非空判断
- pattern 正则表达式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录注册</title>
</head>
<body>
<h1>注册</h1>
<form action="1.我的第一个网页.html" method="get">
<p>姓名:<input type="text" name="username" placeholder="请输入用户名" required></p>
<p>密码:<input type="password" name="pwd"></p>
<p>性别:
<input type="radio" value="boy" name="sex" checked/>男
<input type="radio" value="girl" name="sex"/>女
</p>
<p>爱好:
<input type="checkbox" value="sleep" name="hobby">睡觉
<input type="checkbox" value="code" name="hobby" checked>敲代码
<input type="checkbox" value="chat" name="hobby">聊天
<input type="checkbox" value="game" name="hobby">游戏
</p>
<p>按钮:
<input type="button" name="btn1" value="点击">
<input type="image" src="../resources/image/babe.jpg" width="200" height="200">
</p>
<p>国家:
<select name="列表名称">
<option value="China">中国</option>
<option value="US">美国</option>
<option value="Korea">韩国</option>
<option value="Switzerland" selected>瑞士</option>
<option value="India">印度</option>
</select>
</p>
<p>反馈:
<textarea name="textarea" cols="10" rows="10">文本内容</textarea>
</p>
<p>
<input type="file" name="files">
<input type="button" value="上传" name="upload">
</p>
<p>邮箱:
<input type="email" name="email" required>
</p>
<p>URL
<input type="url" name="url" required>
</p>
<p>商品数量
<input type="number" name="num" max="100" min="0" step="1" required>
</p>
<p>音量
<input type="range" name="voice" max="100" min="0" step="2">
</p>
<p>搜索
<input type="search" name="search" >
</p>
<p>
<label for="mark">点我试试</label>
<input type="text" id="mark">
</p>
<p>自定义邮箱:
<input type="text" name="diymail" pattern="/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/
/^[a-z\d]+(\.[a-z\d]+)*@([\da-z](-[\da-z])?)+(\.{1,2}[a-z]+)+$/或\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">
</p>
<p>
<input type="submit">
<input type="reset" value="清空表单">
</p>
</form>
</body>
</html>