禁用HTML自动填充 [英] Disable autofill in HTML
本文介绍了禁用HTML自动填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在两个密码字段中禁用自动完成功能,但是我做不到.在文本框上使用自动完成=关闭"功能可以正常工作,但在密码字段上则无法使用.预先谢谢你.
I'm trying to disable autocomplete in two password fields but i couldn't do it. It worked fine with the "autocomplete = off" on textboxes but it didn,t work on password fields. Thank you in advance.
<div class="form-group" autocomplete="new-password">
@Html.LabelFor(m => m.Password, new { @class = "col-md-5 control-label" })
<div class="col-md-5">
@Html.PasswordFor(m => m.Password, new { @Title = Password, @class = "form-control", @autocomplete = "new-password" })
</div>
</div>
<div class="form-group" autocomplete="new-password">
@Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-5 control-label" })
<div class="col-md-5">
@Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control", @autocomplete = "new-password" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-5">
<input type="submit" class="btn btn-default" value="Confirmer" />
</div>
</div>
推荐答案
您可以尝试一下.
-
将所有html元素的标签用作根.并在该标签上使用 autocomplete ="off" .
然后使用 autocomplete ="false" 添加隐藏内容作为表单的第一个子元素.
Then add hidden with autocomplete="false" as a first children element of the form.
如果这不起作用,请随时提出要求.
If this is not working, feel free to ask for that.
例如: https://gist.github.com/niksumeiko/360164708c3b326bd1c8
这篇关于禁用HTML自动填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文