Disable autofill on a web form through HTML or Jav

2019-01-15 12:35发布

Is there a way to disable autofill in Chrome and other browsers on form fields through HTML or JavaScript? I don't want the browser automatically filling in answers on the forms from previous users of the browser.

I know I can clear the cache, but I can't rely on repeatedly clearing the cache.

4条回答
smile是对你的礼貌
2楼-- · 2019-01-15 13:13

You can do it at the input level in HTML by adding "autocomplete="off" to the input.

http://css-tricks.com/snippets/html/autocomplete-off/

You could also do it via JS such as:

someForm.setAttribute( "autocomplete", "off" ); 
someFormElm.setAttribute( "autocomplete", "off" );
查看更多
小情绪 Triste *
3楼-- · 2019-01-15 13:18

In fact autocomplete off doesn't always work in newer browsers. E.g in Chrome it is ignored if the autofill property is set. See the link: http://caniuse.com/#feat=input-autocomplete-onoff

查看更多
叛逆
4楼-- · 2019-01-15 13:28

jQuery one:

$(".indication-checkbox").attr("autocomplete", "off");
查看更多
你好瞎i
5楼-- · 2019-01-15 13:28

You can use this code:

$(".TextID").attr("autocomplete", "off"); //disable input level 
查看更多
登录 后发表回答