Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
haizhilin2013 opened this issue Apr 28, 2019 · 20 comments
Open

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

haizhilin2013 opened this issue Apr 28, 2019 · 20 comments
Labels
html html

Comments

@haizhilin2013
Copy link
Collaborator

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

@haizhilin2013 haizhilin2013 added the html html label Apr 28, 2019
@yxkhaha
Copy link

yxkhaha commented Apr 29, 2019

设置form的autocomplete属性为off

@chenliwen123
Copy link

autocomplete="off"

@seho-dev
Copy link

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

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

@Konata9
Copy link

Konata9 commented Jul 27, 2019

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

@hc951221
Copy link

hc951221 commented Aug 7, 2019

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

@haizhilin2013
Copy link
Collaborator Author

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

@LeiDeMing
Copy link

LeiDeMing commented Sep 19, 2019

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(); //阻止默认事件,防止自动提交
 }

@wython
Copy link

wython commented Dec 10, 2019

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

@zlqGitHub
Copy link

zlqGitHub commented Dec 29, 2019

操作表单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>

@lishichengyan
Copy link

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

@blueRoach
Copy link

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

@giggleCYT
Copy link

autocomplate="off"

@Nehic
Copy link

Nehic commented Jan 5, 2021

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

@buuug7
Copy link

buuug7 commented Jan 16, 2021

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

上面回答使用 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.

@xiezhenghua123
Copy link

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

@amikly
Copy link

amikly commented Oct 31, 2021

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

@syfine
Copy link

syfine commented Apr 13, 2022

autocomplete = "off"

@WangXi01
Copy link

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

@Iambecauseyouare
Copy link

将autocomplete的属性设置为off

@lili-0923
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
html html
Projects
None yet
Development

No branches or pull requests