标签:无法 生日 提交 school firefox sea asp 限制 mep
HTML5 增加了多个新的输入类型:
<input type="number"> 用于应该包含数字值的输入字段。
能够对数字做出限制。
根据浏览器支持,限制可应用到输入字段。
<form action="/demo/demo_form.asp"> 数量(1 到 5 之间): <input type="number" name="quantity" min="1" max="5"> <input type="submit"> </form>
数量(1 到 5 之间):
这里列出了一些常用的输入限制(其中一些是 HTML5 中新增的):
属性 | 描述 |
---|---|
disabled | 规定输入字段应该被禁用。 |
max | 规定输入字段的最大值。 |
maxlength | 规定输入字段的最大字符数。 |
min | 规定输入字段的最小值。 |
pattern | 规定通过其检查输入值的正则表达式。 |
readonly | 规定输入字段为只读(无法修改)。 |
required | 规定输入字段是必需的(必需填写)。 |
size | 规定输入字段的宽度(以字符计)。 |
step | 规定输入字段的合法数字间隔。 |
value | 规定输入字段的默认值。 |
<input type="date"> 用于应该包含日期的输入字段。
根据浏览器支持,日期选择器会出现输入字段中。
<form>
Birthday:
<input type="date" name="bday">
</form>
生日:
<input type="color"> 用于应该包含颜色的输入字段。
<form action="action_page.php">
Select your favorite color:
<input type="color" name="favcolor" value="#ff0000">
<input type="submit">
</form>
Select your favorite color:
<input type="range"> 用于应该包含一定范围内的值的输入字段。
根据浏览器支持,输入字段能够显示为滑块控件。
<form action="/demo/demo_form.asp" method="get"> Points: <input type="range" name="points" min="0" max="10"> <input type="submit"> </form>
Points:
能够使用如下属性来规定限制:min、max、step、value。
<input type="month"> 允许用户选择月份和年份。
根据浏览器支持,日期选择器会出现输入字段中。
<form action="/demo/demo_form.asp">
生日(月和年):
<input type="month" name="bdaymonth">
<input type="submit">
</form>
生日(月和年):
<input type="week"> 允许用户选择周和年。
根据浏览器支持,日期选择器会出现输入字段中。
<form action="action_page.php">
Select a week:
<input type="week" name="year_week">
<input type="submit">
</form>
Select a week:
注释: Internet Explorer 不支持 type="week"。
<input type="time"> 允许用户选择时间(无时区)。
根据浏览器支持,时间选择器会出现输入字段中。
<form action="/demo/demo_form.asp">
请选取一个时间:
<input type="time" name="usr_time">
<input type="submit">
</form>
请选取一个时间:
注释:Firefox 或者 Internet Explorer 11 以及更早版本不支持 type="time"。
<input type="datetime"> 允许用户选择日期和时间(有时区)。
根据浏览器支持,日期选择器会出现输入字段中。
<form action="action_page.php">
生日(日期和时间):
<input type="datetime" name="bdaytime">
<input type="submit">
</form>
生日(日期和时间):
注释:Chrome、Firefox 或 Internet Explorer 不支持 type="datetime"。
<input type="datetime-local"> 允许用户选择日期和时间(无时区)。
根据浏览器支持,日期选择器会出现输入字段中。
<form action="/demo/demo_form.asp">
生日(日期和时间):
<input type="datetime-local" name="bdaytime">
<input type="submit" value="Send">
</form>
注释:Firefox 或者 Internet Explorer 不支持 type="datetime-local"。
<input type="email"> 用于应该包含电子邮件地址的输入字段。
根据浏览器支持,能够在被提交时自动对电子邮件地址进行验证。
<form action="/demo/demo_form.asp"> E-mail: <input type="email" name="email"> <input type="submit"> </form>
注释:IE9 及更早版本不支持 type="email"。
<input type="search"> 用于搜索字段(搜索字段的表现类似常规文本字段)。
<form action="/demo/demo_form.asp">
搜索谷歌:
<input type="search" name="googlesearch">
<input type="submit">
</form>
搜索谷歌:
<input type="tel"> 用于应该包含电话号码的输入字段。
目前只有 Safari 8 支持 tel 类型。
<form action="action_page.php">
Telephone:
<input type="tel" name="usrtel">
<input type="submit">
</form>
注释:Safari 8 及更新版本支持 type="tel"。
<input type="url"> 用于应该包含 URL 地址的输入字段。
根据浏览器支持,在提交时能够自动验证 url 字段。
某些智能手机识别 url 类型,并向键盘添加 ".com" 以匹配 url 输入。
<form action="action_page.php">
请添加您的首页:
<input type="url" name="homepage">
<input type="submit">
</form>
Note:IE9 及其更早版本不支持 type="url"。
标签:无法 生日 提交 school firefox sea asp 限制 mep
原文地址:https://www.cnblogs.com/TianLiang-2000/p/12468856.html