【问题标题】:Disabling Chrome Autofill for a DropdownList为 DropdownList 禁用 Chrome 自动填充
【发布时间】:2023-03-25 08:42:02
【问题描述】:

我对下拉列表中的 Chrome 自动填充有一个相当恼人的问题。下拉列表选择一个县以添加许可费用。当您自动填写地址时,它会在下拉列表中选择自动填写的县名,然后依次添加许可证费用。我尝试从selCounty 修改下拉列表ID,但没有成功。

根据情况,可能不需要支付许可费,因此我可以看到客户可能在自动填充时无意中选择了此选项。

我查看了与用户名/密码问题相关的类似 SO 问题,并尝试使用隐藏的下拉菜单来选择它,而不是在没有运气的情况下在黑暗中进行野刺。

这是下拉列表代码:

<select id="fakeSelCty" style="display:none"></select>         
@Html.DropDownListFor(
    x => x.SelectedPermitCountyId,
    new SelectList(Model.PermitCounties, "PermitCountyId", "PermitCounty"),
    new { @class = "form-control  input-sm", id = "selCty" })

autocomplete="off" 的任何建议在 Chrome 中不起作用?

【问题讨论】:

标签: google-chrome html.dropdownlistfor autofill


【解决方案1】:

修好了!

我使用了这个解决方案@readonly = "readonly", onfocus = "this.removeAttribute('readonly');""

取自the third answer here。我修改了 CSS 以更改只读外观,以免混淆用户。

【讨论】:

    猜你喜欢
    • 2019-04-10
    • 2013-03-22
    • 2019-02-17
    • 2016-10-02
    相关资源
    最近更新 更多