fe-interview icon indicating copy to clipboard operation
fe-interview copied to clipboard

[html] 第13天 html5中的form怎么关闭自动完成?

Open haizhilin2013 opened this issue 6 years ago • 21 comments
trafficstars

第13天 html5中的form怎么关闭自动完成?

haizhilin2013 avatar Apr 28 '19 21:04 haizhilin2013

设置form的autocomplete属性为off

yxkhaha avatar Apr 29 '19 12:04 yxkhaha

autocomplete="off"

chenliwen123 avatar Jul 10 '19 07:07 chenliwen123

h5新增的补全功能,菜鸟教程上写的比较含糊比较难懂; 解释: 在部分浏览器上,foucs输入框可以把之前输入过的值自动填入,如果不想自动填入,可以关掉它; autocomplete="off" 默认是"on" 开启状态

一般业务下不会调整这个自动完成,因为对产品来说简化用户操作,建议打开

seho-dev avatar Jul 26 '19 04:07 seho-dev

input 标签中,可以设置 autocomplete="off" 来关闭自动完成。 但这个属性在不同的浏览器上兼容并不好,因此需要配合 type="newpassword" 等其他属性来关闭自动完成。

Konata9 avatar Jul 27 '19 06:07 Konata9

看到这个问题我懵逼了,不知道啥是自动完成

hc951221 avatar Aug 07 '19 03:08 hc951221

@hc951221 正好学习下,查漏补缺

haizhilin2013 avatar Aug 07 '19 03:08 haizhilin2013

TIM截图20190919152612.png 我来科普啦!

<form action="" id="formDom">
        <label for="in1">请输入</label><input id="in1" type="text" >
        <input type="submit" value="提交"  autocomplete='off'>
</form>

let formDom=document.querySelector('#formDom')
    formDom.onclick=function(e){
         e.preventDefault(); //阻止默认事件,防止自动提交
 }

LeiDeMing avatar Sep 19 '19 07:09 LeiDeMing

自动补全,自动完成第一反应不知道问的啥

wython avatar Dec 10 '19 06:12 wython

操作表单form的autocomplete属性值

<form action="demo_form.html" method="get" autocomplete="off">
  First name:<input type="text" name="fname"><br>
  E-mail: <input type="email" name="email"><br>
  <input type="submit">
</form>

zlqGitHub avatar Dec 29 '19 02:12 zlqGitHub

也许把问题改成“自动填充”或者“自动补全”会好一点。

lishichengyan avatar Feb 24 '20 05:02 lishichengyan

autocomplete=“off“ 默认是开启的,作用是你之前输入过并且提交过的表单,再次输入时会有会有自动补全的下拉

blueRoach avatar May 29 '20 07:05 blueRoach

autocomplate="off"

giggleCYT avatar Jun 08 '20 08:06 giggleCYT

密码加onfocus="this.type='password" <input type="text" onfocus="this.type='password">

Nehic avatar Jan 05 '21 09:01 Nehic

首先这个问题是一个不值得回答的问题,浏览器的自动填充功能是现代浏览器必备的功能,设计出来就是要使用的,没事你关闭干嘛。

上面回答使用 autocomplete="off" 在浏览器中并不会一直起作用,跨浏览器关闭自动填充并没有一个标准的写法,尤其在网站的登录界面,即使你已经设置了 autocomplete 为 off, 但是浏览器仍旧会自动填充,详情查看the_autocomplete_attribute_and_login_fields

如果非要关闭浏览器自动填充,那么使用google搜索 Turning Off Autofill on browser ,第一条就是正确答案

Turning Off Autofill in Chrome:

1. Click the Chrome menu icon. (Three dots at top right of screen.)
2. Click on Settings.
3. In the "Autofill" section, expand the area for which you wish to disable Autofill.
4. Toggle the setting OFF if it is on. The system will automatically save your settings.

buuug7 avatar Jan 16 '21 09:01 buuug7

autocomplete="off",浏览器默认开启

xiezhenghua123 avatar Apr 13 '21 04:04 xiezhenghua123

  • 在IE的Internet选项菜单里的内容--自动完成里面设置
  • 设置form的autocomplete为"on"或者"off"来开启或者关闭自动完成功能(关闭整个表单(form)自动提示功能)
  • 设置输入框(input)的autocomplete为"on"或者"off"来开启或者关闭该输入框的自动完成功能(关闭密码域的自动完成)

amikly avatar Oct 31 '21 13:10 amikly

autocomplete = "off"

syfine avatar Apr 13 '22 06:04 syfine

第一时间以为是form表单的自动提交,看了评论才看清楚,autocomplete设置为off,但是有时不生效,这个时候要修改type为newpassword

WangXi01 avatar Jul 13 '22 05:07 WangXi01

将autocomplete的属性设置为off

Iambecauseyouare avatar Feb 24 '23 02:02 Iambecauseyouare

在HTML5中,可以通过设置autocomplete属性来控制表单字段的自动完成功能。默认情况下,所有输入类型都会开启自动完成功能。

要关闭特定表单字段的自动完成功能,只需将该字段的autocomplete属性值设为"off"或者其他非空白字符串(如"false")即可

lili-0923 avatar Feb 04 '24 02:02 lili-0923