您的位置:首页 > Web前端 > HTML5

9 HTML5之表单

2017-02-23 11:46 148 查看

HTML5表单

HTML5的表单组件大致分为了四类:文字组件,列表组建,选择组件,按钮组件。
表单的标记是<form></form>,各种表单组件需放在<form></form>标记内。


<form></form>标记

语法:<form method=[@""](https://my.oschina.net/u/2433434) action=[@""](https://my.oschina.net/u/2433434)>


method

该属性用于设置发送数据的方式,有get和post两种,
至于做过移动端的开发的童鞋都清楚,在这就不多说了,哈哈


action

该属性表示将数据发往哪里,
如果是发往电子邮件,其语法:<form method=@"get" action=@"mailto:wewqdas@qq.com?subject=dsaj" enctype="text/plain">


enctype
enctype表示表单的编码方式,只有post时有效,共三种方式:
1.enctype="application/x-www-form-urlencode":默认值,如果忽略,表示采用此种编码
2.enctype="multi/form-data":用于文件上传
3.enctype="text/plain"表示将表单属性发往电子邮箱时,必须将设为这种属性,不然乱码

autocomplete
用来设置input组件是否使用自动完成功能

novalidate
用来设置是否在发送表单时验证表单,如果需要验证填入novalidate。

实际练习效果



参考代码

<!doctype html>

<html>

<head>
<title> 我的博客首页 </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<html lang="zh-CN">

</head>

<body>

<form method="post" action="mailto:1054539558@qq.com?subject=练习哈哈哈哈" enctype="text/plain">

账号:<input type="text" name="username" /> <br />
密码:<input type="text" name="userpassword"> <br />

<input type="submit" value="提交">
<input type="reset" value="取消">

</form>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  前端 H5 移动端