I have an input for getting password from user :
<input name="Password" id="Password" required/>
in most devices browser will try to autocomplete the password input ( based on saved passwords ),
but lets say we don’t want this behavior , **so how could we turn off autocomplete for an input? **
after searching and trying to turn off autocomplete found this solution,
set attribute autocomplete to off :
<input name="Password" id="Password" required autocomplete="off"/>
but it didn’t work, when page loads this will happen , i tried JavaScript too but it didn’t worked neither
$("#Password").val('')
2
Answers
The solution for Chrome is to add autocomplete="new-password" to the input type password. Please check the example below.
Example:
Chrome always autocomplete the data if it finds a box of type password, just enough to indicate for that box autocomplete = "new-password".
Note: make sure with CTRL + F5 that your changes take effect. Many times, browsers save the page in the cache.
There are 3 ways you could do this:-
autocomplete = "off"
Example:-
autocomplete = "off"
Example:-
Example:-
The first 2 solutions might not work since modern browsers provide a feature to save passwords i.e, they may ask to save the login credentials which will prevent the
autocomplete = "off"
to act.For Reference:-
https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion