Solutions
I have recently encountered a situation where I had to turn off the autocomplete option for filling out the saved passwords by browser.
It was interesting to find out that there is a way to turn this option off. One can consider this for a security reason but to me it was about turning it off on the new password page. Browser was filling out the new password field with the saved password >_O
There are two ways to turn it off in field level!
Field Level in general
1 | <input name="ashkeys" type="text" autocomplete="off" /> |
Even though few browsers support autocomplete, there are cases they ignore all together. Login or Sign-up forms for example. In those cases, the following helps.
Field Level for new passwords
1 | <input name="ashkeys" type="password" autocomplete="new-password" /> |
Form Level
1 | <form autocomplete="off"> |
Special case for all browsers
The below one is kind of hacky way to trick the browser than turn off the autocomplete option. /O\ One should consider this as a last resort to solve the problem.
1 | <form> |
Yeah, you are right! We are cheating the browser here by declaring the first password field hidden so that browser will the saved password there.