HTML5表单新增元素和属性(1)
来源:互联网 发布:ios pdf阅读器源码 编辑:程序博客网 时间:2024/05/22 12:51
HTML5表单新增元素和属性
- HTML5表单新增元素和属性
- form属性和formaction属性
- formaction属性
- formmethod
- formenctype
- formtarget元素
- autofocus属性
- required属性
- labels属性
form属性和formaction属性
指定一个form属性,属性值为改表单的id,这样就可以声明该元素从属于指定的表单了。
<html> <head> <meta charset="UTF-8"> <title>form</title> </head> <body> <form> <input type = "text"> <textarea from = "testform"></textarea> </form> <!-- 作者:offline 时间:2017-10-09 描述:html5新增写法 --> <form id = 'testform'> <input type = "text" /> </form> <textarea form = "testform"></textarea> </body></html>
formaction属性
<html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <form id= "testform"> <input type= "submit" name="s1" value="v1" formaction="http://localhost:8080/helloJSP/test01.jsp" />提交到第一个页面 <input type= "submit" name="s2" value="v3" formaction="http://localhost:8080/helloJSP/test02.jsp" />提交到第二个页面 <input type= "submit" name="s3" value="v3" formaction="http://localhost:8080/helloJSP/test03.jsp" />提交到第三个页面 </form> </body></html>
formmethod
使用 formmethod属性来对每一个表单元素分别指定不同的提交方法
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <form id="testform"> <input type="submit" name="s1" value="v1" formmethod="post" formaction="http://localhost:8080/helloJSP/test01.jsp"/>提交 <input type="submit" name="s2" value="v2" formmethod="get" formaction="http://localhost:8080/helloJSP/test02.jsp"/>提交 </form> </body></html>
注意post和get方法的区别
formenctype
使用formenctype属性对表单元素分别制定不同的编码方式
<form id="testform"> <input type="text" formenctype="text/plain"/> <input type="text" formenctype="multipart/form-data"/> </form>
formtarget元素
可以对多个提交按钮分别使用formtarget属性来指定提交后在何处打开所需加载的页面。
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <form id= "testform"> <input type= "submit" name="s1" value="v1" formtarget="_blank" />提交到第一个页面 <input type= "submit" name="s2" value="v3" formtarget="_parent" />提交到第二个页面 <input type= "submit" name="s3" value="v3" formtarget="_self"/>提交到第三个页面 <input type= "submit" name="s3" value="v3" formtarget="_top"/>提交到第三个页面 <input type= "submit" name="s3" value="v3" formtarget="framename"/>提交到第三个页面 </form> </body></html>
_blank 在空白页中打开 _parent 在当前框架的父框架打开 _self 相同框架的frame中打开 _top 在当前窗口中打开 framename 在指定框架中打开
autofocus属性
为文本框、选择框或者按钮控件加上autofocus属性,当画面打开时,该控件自动获得光标焦点。
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <form> <input type="text" /> <input type="text" autofocus/> </form> </body></html>
把光标焦点放在第二个框上
required属性
应用在大多数输入元素上,在提交时,如果元素内容为空白,则不允许提交,同时在浏览器中显示信息提示文字。
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <form action="http://localhost:8080/helloJSP/test01.jsp"> <input type="text" required="required" /> <button type="submit">提交</button> </form> </body></html>
labels属性
在html5中,为所有可使用标签的表单元素、button、select元素等,定义一个labels属性,属性值为一个NOdeList对象,代表该元素所绑定的表圈元素所构成的集合。
阅读全文
0 0
- HTML5表单新增元素和属性(1)
- HTML5表单相关新增元素和属性
- HTML5-表单相关新增元素和属性
- HTML5表单相关新增元素和属性
- HTML5表单新增元素和属性(2)
- HTML5-表单新增元素和属性
- html5篇——新增表单元素和表单属性
- HTML5初探——新增的表单元素和属性
- HTML5 学习笔记4-表单新增的元素和属性
- HTML5——表单新增元素与属性(1)
- HTML5表单新增元素与属性
- HTML5表单新增元素与属性
- HTML5表单新增元素与属性
- HTML5表单新增元素与属性
- HTML5表单新增元素与属性
- HTML5 表单新增元素与属性
- HTML5新增表单元素及属性总结
- html5表单新增元素属性2
- Python安装中需要特别注意的一件事
- c++ vector 删除, map
- SmartRefreshLayout源码分析
- 63、java集合-HashSet
- Java中的static关键字解析
- HTML5表单新增元素和属性(1)
- C++ 编译错误cannot allocate an object of abstract type“xx”
- jsp+servlet文件上传
- hue快速入门--Hadoop可视化分析利
- Excel2013如何让数据按照小数点对齐方便观察数据大小
- 给你看八个网页特效,让你的网站建设更加引人入胜!
- SpringBoot(1) Spring Boot快速入门
- 64、java集合-LinkedHashSet
- 微信小程序loading请求提示框