EmilMoe's avatar

Autocomplete off on text inputs

Is there a way to prevent autocomplete? Internet Explorer allows autocomplete="off" but Chrome doesn't.

My problem is that I have a web app, where to login the input is name="password" and in the settings you can show some private information that requires password, which then has the name="password". But since people save their login informations, the password is pre-provided. It's really a fault on the user side, but I want to mask it with an empty field if I can, but I don't want to change input names.

0 likes
5 replies
michaelmcmullen's avatar

Chrome should still allow you to do an autocomplete on the entire form (if that is what you want)

<form action=".." method="..." autocomplete="off">
    ... rest of normal controls like
  <input type="text" name="email">
</form>

The other solutions I have seen is hiding a password field on the page as people have reported that Chrome will only autocomplete the first password field it finds... Try turning off autocomplete on the entire form first.

EmilMoe's avatar

I just checked. That's unfortunately not the case, on the entire form still same problem.

The second solution seems too unstable for me. A Javascript that empties the field might be the only solution?

jekinney's avatar

Chromed auto complete is client side that has little to do with your code. As @Qlic link shows you have to trick chrome.

EmilMoe's avatar
EmilMoe
OP
Best Answer
Level 10

Thanks. It didn't work though. It works if I change to this:

<input type="password" name="password" style="display:none">

But I'm not sure if that makes it fail in some browsers.

A manual tests shows it works in:

  • Firefox
  • Chrome
  • Internet Explorer
  • Edge
  • Safari

So it seems like a solution for now. Thanks.

Please or to participate in this conversation.