我们有一个单页应用程序,使用AngularJS构建。与许多应用程序一样,我们有一个登录表单,其中包含一个input[type=text]
(电子邮件)和一个input[type=password]
(密码)。好的。 Firefox会保存数据(如果用户确认),并且可以在下次自动填写表单。
我们还有一个用于编辑或创建用户的表单。当然,还有类型为text
和password
的输入字段。 Firefox在任何情况下都会为任何用户自动填充这些字段。
我们的用户编辑表单:
<!--span>made by selectize directive: no id, no name<span-->
<input type="text" tabindex="0"></input>
<input
id="whatever"
autocomplete="off"
class="form-control"
name="hi"
ng-minlength="settings.loginSettings.passwordMinLength"
ng-model-options="{debounce: {'default': 500, 'blur': 0}}"
ng-model="userData.password"
ng-required="!userData.id"
placeholder="{{ '_settings.password' | translate }}"
type="password" />
我们的表单与登录表单不同id
,它具有autocomplete="off"
属性(which is turned off in FF >= 30,although it is apparently HTML5 standard),密码字段具有不同的name
}和id
属性,而不是登录表单中的属性。
其他建议,例如添加一个隐藏的(style="display: none"
)文本输入字段不起作用。
我在用户编辑控制器中创建了一个非常脏的JS hack,它清空了脏字段和相关的模型字段,但用户确实看到页面上发生了奇怪的事情。
此问题的Most discussions已经相当陈旧了,但另一方面,大量应用程序的登录表单和是用户编辑表单。我想我们在这里缺少一些简单的东西?
感谢您的任何建议!
答案 0 :(得分:2)
我通过添加虚假字段以上真实字段来解决同样的问题。
[treeLevel = 2,3,4,5,6,7]
# ... Your code here
[global]
答案 1 :(得分:1)
这是一个旧线程,但是另一种解决方案是在输入字段中设置autocomplete='new-password'
。
<input
id="whatever"
autocomplete="new-password"
class="form-control"
name="hi"
ng-minlength="settings.loginSettings.passwordMinLength"
ng-model-options="{debounce: {'default': 500, 'blur': 0}}"
ng-model="userData.password"
ng-required="!userData.id"
placeholder="{{ '_settings.password' | translate }}"
type="password" />
请参阅MDM web docs