How to disable autocomplete in MVC Html Helper

前端 未结 4 1457
我寻月下人不归
我寻月下人不归 2020-12-28 11:44

I have a typical ADO.NET EF-driven form that allows the user to input a date. I have put a jQuery datepicker on it but when the user goes to select a date the browser shows

4条回答
  •  情深已故
    2020-12-28 12:22

    Couple of points

    1. If you've more or less already written the site and you don't want to go back and modify all your cshtml to disable autocomplete (we would have had to go back and change hundreds of lines of code throughout the site), you can disable it via Javascript with a ready handler, like so:

      //Disable autocomplete throughout the site
      $(document).ready(function() {
          $("input:text,form").attr("autocomplete","off");
      })
      
    2. From what I've read you need to disable it at both the form and the textbox level in order for it to work on all versions of Firefox and IE.

提交回复
热议问题