How can I prevent Firefox's Autocomplete?

回眸只為那壹抹淺笑 提交于 2019-11-28 20:28:49

Add autocomplete="off" to your form tag, as documented in the Mozilla document How to Turn Off Form Autocompletion

<form name="form1" id="form1" method="post" autocomplete="off"
  action="http://www.example.com/form.cgi">
[...]
</form>

Do read the section on exceptions and workarounds though - the browser will ignore the autocomplete attribute if you have a Name or Address field in the form!

If you don't care about validation, you can use autocomplete="off"

BTW here's a great article from Mozilla themselves about autocompletion

Firefox usually autocompletes based on the field names, so it sounds to me like you might have some underlying confusion with what your fields are called.

I ran into the same problem on Firefox with forms having a 'username' and 'password' field. In this case autocomplete="off" doesn't seem to work, as stated here: https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion (bottom of page).

The only way I found right know to have en empty fields when opening the page is to empty them in javascript. jQuery code example:

setTimeout(function(){
    $('input[name="username"],input[name="password"]').val("");
}, 0);

I know it's ugly (especially the setTimeout but I couldn't figure another way. Even putting this in $(window).load() doesn't seem to work.

sumantakec

If autocomplete="off" in the form fails, try using autocomplete="off" in the input field directly and hit Ctrl + F5.

Try to use dynamic input names.

Actually, since a few weeks I've noticed Firefox started mixing autofill values, dropdownlists show entries even from different sites. They probably broke something in their recent builds. Now some personal entries can be seen by people just asking to check mails on your pc. Desire to block this feature is now very understandable.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!