HTML5的form如何关闭自动完成功能

html-css09

HTML5的form如何关闭自动完成功能,第1张

找到IE浏览器Internet选项里的内容进行设置

2.设置Form元素的autocomplete为“on”或者“off”来开启或者关闭自动完成功能

3.设置input输入框的autocomplete为“on”或者“off”来开启或者关闭该输入框的自动完成功能(关闭密码域的自动完成)

代码实例:

<!-- 打开自动完成功能的Form  -->

<form name="form1" autocomplete="on">  

    <!-- 打开自动完成功能的输入框   -->

    <input type="text" autocomplete="on" name="user">  

    <!-- 关闭自动完成功能的输入框   -->

    <input type="password" autocomplete="off" name="password">

</form>  

<!-- 关闭自动完成功能的Form  -->

<form name="form1" autocomplete="off">  

    <!-- 打开自动完成功能的输入框   -->

    <input type="text" autocomplete="on" name="user"> 

    <!-- 关闭自动完成功能的输入框   -->

    <input type="password" autocomplete="off" name="password"> 

</form>

表单的更多内容详见:《form表单存在的常见兼容问题》

<form action="#" method="post" id="form1"></form>

<form action="#" method="post" id="form2"></form>

<form action="#" method="post" id="form3"></form>

<input type="submit" name="" form="form1 form2 form3" value="提交"/>

点击提交的时候会同时提交三个表单的值;

这是html5 的新特性,测试的时候注意使用支持html5 的浏览器才能有效果

1、form表单:网址与用户交互,把浏览者输入的数据传送到服务器端,这样服务器端程序就可以处理表单传过来的数据。

语法: <form method="传送方式" action="服务器文件">

          <form>: 标签是成对出现的,以开始,以</form>结束。

          action   : 浏览者输入的数据被传送到的地方,比如一个PHP页面(save.php)。

          method   :  数据传送的方式(get/post)。

2、文本输入框、密码输入框

语法:

<form>

  <input type="text/password" name="名称" value="文本" />

</form>

type:

当type=" text "时,输入框为 文本 输入框

当type=" password "时, 输入框为 密码输入框。

name: 为文本框命名,以备后台程序ASP 、PHP使用。

value: 为文本输入框设置默认值。(一般起到提示作用)

3、占位符placeholder,属性,有时候需要提示用户输入框需要输入框的内容

     4、input标签中的数字框number类型

       <input type="number"/>  :输入框中只能输入数字,输入其他字符无效,输入框右侧会有加减符号,可以调整输入数字的大小,浏览器不同表现不一致。

5、input标签中的网址框url类型

<input type="url"/>: 数字框的值需以http://或者https://开头,且后面必须有内容,否则表单提交的时候会报错误提示

6、input标签中的邮箱框的email类型

    <input type="email" />: 表示该输入框的类型为邮箱;数字框的值必须包含@;数字框的值@之后必须有内容,否则会报错误提示。

7、<textarea>标签创建文本域

      语法:  <textarea rows=" 行数" cols=" 列数" >文本</textarea>

8、label为input标签穿上衣服:如果你在 label 标签内点击文本,就会触发此控件。就是说,当用户单击选中该label标签时,浏览器就会自动将焦点转到和标签相关的表单控件上(就自动选中和该label标签相关连的表单控件上)

        语法:<label for="控件id名称">(标签的 for 属性中的值应当与相关控件的 id 属性值一定要相同。)

9、单选框、复选框

    <input type="radio/checkbox" value="值"name="名称" checked="checked"/>

    type:    当  type="radio"  时,控件为 单选框

                当  type="checkbox"  时,控件为 复选框

     value: 提交数据到服务器的值(后台程序PHP使用)

     name: 为控件命名,以备后台程序 ASP、PHP 使用

     checked: 当设置 checked="checked" 时,该选项被默认选中

        注意: 同一组 的单选按钮,name 取值一定要一致,比如上面例子为同一个名称“radioLove”,这样同一组的单选按钮才可以起到单选的作用。

10、使用select option创建下拉菜单 (select标签里面只能放option标签,表示下拉列表的选项)

        设置selected="selected"属性,则该选项就被默认选中。

    11、提交/重置 按钮

      语法:<input type="submit"value="提交">

                <input  type="reset"  value="重置">