本章全面介绍这些新的输入类型:
- email 包含 e-mail 地址的输入域,在提交表单时,会自动验证 email 域的值。
- url 包含 URL 地址的输入域
- number 包含数值的输入域,够设定对所接受的数字的限定
- range 滑动条
- Date pickers (date, month, week, time, datetime, datetime-local)
- search 用于搜索域,比如站点搜索或 Google 搜索,search 域显示为常规的文本域。
- color
HTML5 拥有多个可供选取日期和时间的新输入类型:
- date - 选取日、月、年
- month - 选取月、年
- week - 选取周和年
- time - 选取时间(小时和分钟)
- datetime - 选取时间、日、月、年(UTC 时间)
- datetime-local - 选取时间、日、月、年(本地时间)
e-mail:<input type="email" name="user_email" />
homepage:<input type="url" name="user_url" />
points:<input type="number" name="points" min="1" max="10" />
<input type="range" name="points" min="1" max="10" />
date:<input type="date" name="user_date" />
month:<input type="month" name="user_month" />
week:<input type="week" name="user_week" />
time:<input type="time" name="user_time" />
datetime:<input type="datetime" name="user_datetime" />
datetime-local:<input type="datetime-local" name="user_datetime-local" />