Is it possible to stop browser from autofilling password field programmatically?

Hi

Does anyone know if it’s possible to stop Safari (and other browsers) from prompting possible previous or new passwords?

Thanks for any help!

you can ask for 2 passwords, most of browsers won’t remember 2 simultaneously
you can make some java keypad to enter the code, so impossible to remember for the borwser
you can also use autocomplete=off
more here : https://stackoverflow.com/questions/41217019/how-to-prevent-a-browser-from-storing-password

Thanks for your reply Jean-Yves.

autocomplete=off doesn’t seem to stop it and I think the above is already effectively asking for two password (a password and a pin) so that doesn’t seem to be doing the trick - the only option left from yours is a java keyboard (which is obviously a little more work than if autocomplete=off had worked!)

Thanks again for responding

ask one password on first screen, and second on another screen.
should disturb browsers a little.

Thanks Jean-Yves! I’ll try that :slight_smile:

More and more this functionality is built-in and unavoidable. If the field is marked as a password field then it’ll show this.

It could be avoided using javascript (not java) but probably the easiest way is to add CSS to hide “hints” from the OS:

input::-webkit-textfield-decoration-container { display: none; /* this hides all decorations for text fields */ }
You can targer individual decorations, if you prefer:

input::-webkit-caps-lock-indicator { display: none; /* caps-lock indicator */ } -webkit-credentials-auto-fill-button { display: none; /* key icon */ }
input::
And other browsers have different ones:

input::-ms-clear { display: none; /* "X" that clears text fields */ } input::-ms-reveal { display: none; /* eye icon that shows the password */ }

There are more decorations that can be targeted in the same way:

-webkit-inner-spin-button ← Small spinner in Safari
-webkit-outer-spin-button ← Larger spinner in Safari
-moz-placeholder ← Placeholder text in Mozilla
-ms-input-placeholder ← Placeholder text in IE

This an outdated list:

Safari has more pseudo-elements that any other browser, I think:

Thanks very much Eduardo Gutierrez! I’ll try this out.

Thanks again for responding :slight_smile:

No idea if this sort of approach might work, I’m afraid I don’t have time to test it…

You might try setting it readonly until the form is shown - then clear it and make it writeable - sort of depends of when the browser populates it, I guess.

If readonly does not work, somethign similar using visibility might work.

Interesting idea Chris. I’ll give it a try. I suspect a timer may need to be employed as well.

No luck Chris - With the try anyway and thanks for the feedback,

Eduardo, that was really useful info, thanks!. It seems to be working so far (for Safari anyway!) - At least it doesn’t seem to think the page is looking for a new password any more, which was the most frustrating part.

Thanks again