html5表单标签

来源:互联网 发布:淘宝上怎么买淘宝小号 编辑:程序博客网 时间:2024/06/16 18:10

type=email               限制用户输入的必须为email格式

type=url                 限制用户输入的必须为url格式(带协议的)

type=date                 限制用户输入的必须为日期格式

type=time               限制用户输入的必须为时间类型

type=number           限制用户输入的必须为数值类型

type=month

type=week

type=range

type=search

type=color

2)、html5新增表单属性

  所有的表单选项可以增加 form属性,值等于form表单的id,以后一个网页的不同地方需要使用表单的时候,给每个表单增加form属性,表单项指向form表单的id

3)、新增的表单属性:

required:必填

placeholder 默认值,给用户提示的,不是提交到服务器的

autofocus  自动聚焦功能,提升用户友好

pattern     html元素中填写正则表达式

例:

<form action="12biaodan.php" method="post" id="myid">
用户名:<input type="text" name="username"  placeholder="请填写姓名" autofocus><br />
密码:<input type="password" name="pass" pattern="\d{6}"><br />

邮箱:<input type="email" name="email" required><br /><!--required空白提交给提示-->
地址:<input type="url" ><br /><!--限制用户输入的必须为url格式(带协议的-->
日期:<input type="date" ><br /><!--限制用户输入的必须为日期格式-->
时间:<input type="time" ><br />
数值:<input type="number"><br /><!--限制用户输入的必须为数值类型-->
month:<input type="month"><br />
week:<input type="week"><br />
range:<input type="range"><br />
search:<input type="search"><br />
color:<input type="color"><br />
<input type="submit" value="提交">
</form>
<!-- 所有的表单选项可以 增加 form属性,值等于form表单的id,以后一个网页的不同地方需要使用表单的时候,给每个表单增加form属性,表单项指向form表单的id-->
电话:<input type="text" name="text" form="myid"><!--没有form="myid"是接受不了的-->

 

原创粉丝点击