如何在主要浏览器中禁用特定输入(或表单字段)的自动完成?
当前回答
autocomplete='off'对我不起作用,无论如何,我将输入字段的value属性设置为一个空格,即<input-type='text'name='username'value=“”>,将默认输入字符设置为空格,由于用户名为空,密码也被清除。
其他回答
我已经解决了在页面加载后放置此代码的问题:
<script>
var randomicAtomic = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
$('input[type=text]').attr('autocomplete',randomicAtomic);
</script>
我使用此TextMode=“password”autocomplete=“new password”,并在aspx txtPassword.Attributes.Add(“value”,“”)中加载页面;
您可以在输入中使用它。
例如
<input type=text name="test" autocomplete="off" />
最佳解决方案:
防止自动完成用户名(或电子邮件)和密码:
<input type="email" name="email"><!-- Can be type="text" -->
<input type="password" name="password" autocomplete="new-password">
阻止自动完成字段:
<input type="text" name="field" autocomplete="nope">
说明:autocomplete在<input>中继续工作,autocomplete=“off”不工作,但您可以将off更改为随机字符串,如nope。
工作地点:
铬:49、50、51、52、53、54、55、56、57、58、59、60、61、62、63和64Firefox:44、45、46、47、48、49、50、51、52、53、54、55、56、57和58
我遇到了同样的问题,今天2019年10月9日,我找到的唯一解决方案是
将autocomplete=“off”添加到表单标记中。
打开表单标签后输入1个错误。
<input id="username" style="display:none" type="text" name="fakeusernameremembered">
但它在密码类型字段上不起作用,请尝试
<input type="text" oninput="turnOnPasswordStyle()" placeholder="Enter Password" name="password" id="password" required>
在脚本上
function turnOnPasswordStyle() {
$('#password').attr('type', "password");
}
这在Chrome-78、IE-44、Firefox-69上进行了测试
推荐文章
- 使伸缩项目正确浮动
- 形式内联内的形式水平在twitter bootstrap?
- 自定义元素在HTML5中有效吗?
- 如何触发自动填充在谷歌Chrome?
- 创建圈div比使用图像更容易的方法?
- 为什么Chrome浏览器不正确地确定页面是在不同的语言,并提供翻译?
- 在网页上用鼠标模拟震颤(例如帕金森病)?
- Bootstrap抛出Uncaught错误:Bootstrap的JavaScript需要jQuery
- 如何改变文本区域的边框颜色:焦点
- 我如何设置背景颜色为文本的宽度,而不是整个元素的宽度,使用CSS?
- 如何删除和清除所有的本地存储数据
- 强制打开“另存为…”弹出打开文本链接点击PDF在HTML
- 如何修改标签文本?
- 在HTML中还有其他有用的空格码吗,比如半空格的 , em-spaces, en-spaces等等?
- 输入触发器按钮单击