【问题标题】:Is there a way to disable chrome AUTOFILL and AUTOCOMPLETE for angular form? [duplicate]有没有办法禁用 chrome AUTOFILL 和 AUTOCOMPLETE 的角度形式? [复制]
【发布时间】:2020-11-01 06:03:02
【问题描述】:

我想禁用自动填充和自动完成谷歌浏览器选项 我尝试了变体解决方案,例如:

  • 设置 *autocomplete="off"autocomplete="nope"
  • 设置输入type="search"
  • 自动完成中的未知值,例如 autocomplete="someThingUnknown"

有什么解决办法吗?

【问题讨论】:

  • @str 我尝试了所有这些解决方案,但对我不起作用,我找到了一个新解决方案,我想分享它
  • 好的,谢谢你的建议
  • 很遗憾我无法添加新答案

标签: html angular typescript google-chrome autofill


【解决方案1】:

我找到了解决办法:

1 - 将 input type="text" 设置为只读:

<input type="text" [readonly]="inputText" />

2 - 将输入类型密码设置为输入文本并将css更改为看起来像密码输入:

html:

<input type="text" [readonly]="inputPassword" class="pw-field"/>

css:

.pw-field{
        -webkit-text-security: disc;
 }

3- 为两个输入添加一个 focusEvent:

html:

<input type="text" [readonly]="inputText" (focus)='focusFunction("text")' />

<input type="text" [readonly]="inputPassword" class="pw-field" (focus)='focusFunction("pw")' />

ts:

focusFunction(type){
  if(type == "text"){
        this.inputText = false;
        this.inputPassword = true;
    }else if(type == "pw"){
        this.inputText = false;
        this.inputPassword = true;
    }
}

【讨论】:

    猜你喜欢
    • 2021-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-10
    • 2021-06-28
    • 2014-04-26
    • 2016-10-06
    • 1970-01-01
    相关资源
    最近更新 更多