【问题标题】:Form autocomplete is still working even it has been set to "off" MVC4表单自动完成功能仍然有效,即使它已设置为“关闭”MVC4
【发布时间】:2014-05-13 13:29:50
【问题描述】:

我在我的 Web 应用程序中使用 MVC4。我在特定页面中遇到自动完成问题,即使我设置了 autocomplete="off" 但它仍然可以在登录时记住登录凭据。请帮忙。如何关闭自动完成。我还尝试将 html 属性添加到每个文本框/EditorFor 字段,但没有运气。自动完成表单仍在工作。这是我的页面和视图的屏幕截图。

在浏览器中看到的页面

查看

【问题讨论】:

标签: jquery asp.net-mvc asp.net-mvc-4 autocomplete


【解决方案1】:

试试这些:

<%= Html.TextBoxFor(
    model => model.idName, 
    new { @class = "className", autocomplete = "off" }
)%>

or you can disable with javascript using
$(document).ready(function() {
    $("input:text,form").attr("autocomplete","off");
})

【讨论】:

    【解决方案2】:

    尝试用 jQuery 来做这件事。首先将此代码放在您的 div class="row=fluid"

    之前
     <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
     <script>
      function removeAutoComplete(){
      $("input:text").attr("autocomplete","off");
      }
    
     window.onload=removeAutoComplete;
     </script>
    

    这应该对您的情况有所帮助。

    【讨论】:

      猜你喜欢
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 2018-11-21
      • 1970-01-01
      • 1970-01-01
      • 2011-10-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多