HTML5笔记二 分手后的思念是犯贱 2022-07-19 12:40 127阅读 0赞 转载地址:http://www.cnblogs.com/sailxc/archive/2011/06/24/2089106.html HTML5的新的表单属性 新的form属性: l autocomplete l novalidate 新的input属性: l autocomplete l autofocus l form l form overrides (formaction, formenctype, formmethod, formnovalidate, formtarget) l height和width l list l min, max和step l multiple l pattern (regexp) l placeholder l required autocomplete 属性 autocomplete属性规定form 或input域应该拥有自动完成功能。 autocomplete适用于<form>标签,以及以下类型的<input>标签:text, search, url,telephone, email, password, datepickers, range 以及color。当用户在自动完成域中开始输入时,浏览器应该在该域中显示填写的选项: 示例: <form action=”demo\_form.asp” method=”get” autocomplete=”on”> First name: <input type=”text” name=”fname” /><br /> Last name: <input type=”text” name=”lname” /><br /> E-mail: <input type=”email” name=”email” autocomplete=”off” /><br /> <input type=”submit” /> </form> autofocus属性 autofocus属性规定在页面加载时,域自动地获得焦点。 autofocus属性适用于所有<input>标签的类型。 示例: User name: <input type=”text” name=”user\_name” autofocus=”autofocus” /> form属性 form属性规定输入域所属的一个或多个表单。 form属性适用于所有<input>标签的类型,必须引用所属表单的id: 示例: <form action=”demo\_form.asp” method=”get” id=”user\_form”> First name:<input type=”text” name=”fname” /> <input type=”submit” /> </form> Last name: <input type=”text” name=”lname” form=”user\_form” /> PS:如需引用一个以上的表单,请使用空格分隔的列表。 form overrides属性 form overrides属性允许您重写form 元素的某些属性设定,包括: l formaction – 重写表单的action属性 l formenctype – 重写表单的enctype属性 l formmethod – 重写表单的method属性 l formnovalidate – 重写表单的novalidate属性 l formtarget – 重写表单的target 属性 form overrides属性适用于submit和image类型的<input>标签。这些属性对于创建不同的提交按钮很有帮助。 示例: <form action=”demo\_form.asp” method=”get” id=”user\_form”> E-mail: <input type=”email” name=”userid” /><br /> <input type=”submit” value=”Submit” /><br /> <input type=”submit” formaction=”demo\_admin.asp” value=”Submit as admin” /><br /> <input type=”submit” formnovalidate=”true” value=”Submit without validation” /><br /> </form> height和width属性 height和width属性规定用于image类型的input标签的图像高度和宽度。 示例: <input type=”image” src=”img\_submit.gif” width=”99″ height=”99″ /> list属性 list属性规定输入域的datalist。datalist 是输入域的选项列表。 list属性适用于以下类型的<input>标签:text, search, url, telephone, email, date pickers, number, range 以及color。 示例: Webpage: <input type=”url” list=”url\_list” name=”link” /> <datalist id=”url\_list”> <option label=”W3Schools” value=”[http://www.w3school.com.cn][http_www.w3school.com.cn]” /> <option label=”Google” value=”[http://www.google.com][http_www.google.com]” /> <option label=”Microsoft” value=”[http://www.microsoft.com][http_www.microsoft.com]” /> </datalist> min、max和step属性 min、max和step属性用于为包含数字或日期的input 类型规定限定(约束)。 <table style="border:1px solid silver; border-collapse:collapse; word-break:break-word; color:rgb(75,75,75); font-family:Verdana,Arial,Helvetica,sans-serif; font-size:13px; line-height:20.8px"> <tbody style=""> <tr style=""> <td style="font-family:Verdana,Helvetica,Arial; word-break:break-all; line-height:1.5; border:1px solid silver; border-collapse:collapse; padding:3px"> <p style="margin:10px auto">属性</p> </td> <td style="font-family:Verdana,Helvetica,Arial; word-break:break-all; line-height:1.5; border:1px solid silver; border-collapse:collapse; padding:3px"> <p style="margin:10px auto">描述</p> </td> </tr> <tr style=""> <td style="font-family:Verdana,Helvetica,Arial; word-break:break-all; line-height:1.5; border:1px solid silver; border-collapse:collapse; padding:3px"> <p style="margin:10px auto">max</p> </td> <td style="font-family:Verdana,Helvetica,Arial; word-break:break-all; line-height:1.5; border:1px solid silver; border-collapse:collapse; padding:3px"> <p style="margin:10px auto">规定输入域所允许的最大值</p> </td> </tr> <tr style=""> <td style="font-family:Verdana,Helvetica,Arial; word-break:break-all; line-height:1.5; border:1px solid silver; border-collapse:collapse; padding:3px"> <p style="margin:10px auto">min</p> </td> <td style="font-family:Verdana,Helvetica,Arial; word-break:break-all; line-height:1.5; border:1px solid silver; border-collapse:collapse; padding:3px"> <p style="margin:10px auto">规定输入域所允许的最小值</p> </td> </tr> <tr style=""> <td style="font-family:Verdana,Helvetica,Arial; word-break:break-all; line-height:1.5; border:1px solid silver; border-collapse:collapse; padding:3px"> <p style="margin:10px auto">step</p> </td> <td style="font-family:Verdana,Helvetica,Arial; word-break:break-all; line-height:1.5; border:1px solid silver; border-collapse:collapse; padding:3px"> <p style="margin:10px auto">为输入域规定合法的数字间隔(如果step=”3″,则合法的数是-3,0,3,6等)</p> </td> </tr> </tbody> </table> min、max和step属性适用于以下类型的<input>标签:date pickers、number 以及range。 下面的例子显示一个数字域,该域接受介于0到10之间的值,且步进为3(即合法的值为0、3、6 和9): Points: <input type=”number” name=”points” min=”0″ max=”10″ step=”3″ /> multiple属性 multiple属性规定输入域中可选择多个值。 multiple属性适用于以下类型的<input>标签:email 和file。 示例: Select images: <input type=”file” name=”img” multiple=”multiple” /> novalidate属性 novalidate属性规定在提交表单时不应该验证form或input域。 novalidate属性适用于<form>以及以下类型的<input>标签:text, search, url, telephone, email, password, date pickers, range 以及color. 示例: <form action=”demo\_form.asp” method=”get” novalidate=”true”> E-mail: <input type=”email” name=”user\_email” /> <input type=”submit” /> </form> pattern属性 pattern属性规定用于验证input域的模式(pattern)。 pattern属性适用于以下类型的<input> 标签:text, search, url, telephone, email 以及password。 下面的例子显示了一个只能包含三个字母的文本域(不含数字及特殊字符): Country code: <input type=”text” name=”country\_code” pattern=”\[A-z\]\{3\}” title=”Three letter country code” /> placeholder属性 placeholder属性提供一种提示(hint),描述输入域所期待的值。 placeholder属性适用于以下类型的<input> 标签:text, search, url, telephone, email 以及password。提示(hint)会在输入域为空时显示出现,会在输入域获得焦点时消失: 示例: <input type=”search” name=”user\_search” placeholder=”Search W3School” /> required属性 required属性规定必须在提交之前填写输入域(不能为空)。 required属性适用于以下类型的<input> 标签:text, search, url, telephone, email, password, date pickers, number, checkbox, radio 以及file。 示例: Name: <input type=”text” name=”usr\_name” required=”required” /> [http_www.w3school.com.cn]: http://www.w3school.com.cn/ [http_www.google.com]: http://www.google.com/ [http_www.microsoft.com]: http://www.microsoft.com/
还没有评论,来说两句吧...