0

I don't want my client to store their id and passwords in browsers, because the password field is an OTP.

I tried all the solutions of Prevent Browsers from storing passwords but nothing has worked for me

autocomplete="off" readonly onfocus="this.removeAttribute('readonly');"
autocomplete="new-password"
autocomplete="one-time-code"

These didn't worked.

I also created a hidden password field, it's not auto-filling the actual password field but on click of the password textbox browsers give suggestions which I don't want because it's an OTP.

Any other suggestions?

ANEES
  • 300
  • 3
  • 16
  • The accepted answer is old, have you tried other answers as well? – thedemons Nov 18 '22 at 06:51
  • @thedemons I tried all answers except the css change – ANEES Nov 18 '22 at 06:52
  • Maybe you don't need to worry about that. An OTP is only meant to be used once. Once it's used, it should no longer be use-able. So, if it gets saved, it doesn't matter. – Ouroborus Nov 18 '22 at 07:10
  • @Ouroborus That's an actual issue, when the user is clicking on the password field it's giving suggestion which I don't want. – ANEES Nov 18 '22 at 07:13
  • An alternative is to simulate an input field without actually using ``. Put in a div, bind to `keypress`, and process the password entry manually. In this way nothing ends up in an input field. Accessibility may be difficult to accomplish this way though. – Ouroborus Nov 18 '22 at 07:13
  • What kind of suggestions is it giving? Are you using `type="password"`? – Ouroborus Nov 18 '22 at 07:15
  • @Ouroborus yes `type="password"` – ANEES Nov 18 '22 at 07:17

1 Answers1

0

Try this link here, it should work for you gfg

#javascript

  • 1
    Provide the relevant code and explanation in the answer. Link-only answers are not appropriate for Stackoverflow and will eventually be deleted. – Ouroborus Nov 18 '22 at 07:20
  • As I mentioned in the Question. These solutions are not working – ANEES Nov 18 '22 at 07:21
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 20 '22 at 22:09