I remember seeing a way to have an <input type="password" /> such that the browser will not prompt the user to save the password. But I'm drawing a blank. Is there an HTML attribute or some JavaScript trick that will do this?
I remember seeing a way to have an <input type="password" /> such that the browser will not prompt the user to save the password. But I'm drawing a blank. Is there an HTML attribute or some JavaScript trick that will do this?
Try using autocomplete="off". Not sure if every browser supports it, though. MSDN docs here.
EDIT: Note: most browsers have dropped support for this attribute. See Is autocomplete="off" compatible with all modern browsers?
This is arguably something that should be left up to the user rather than the web site designer.
<input type="password" autocomplete="off" />
I'd just like to add that as a user I think this is very annoying and a hassle to overcome. I strongly recommend against using this as it will more than likely aggravate your users.
Passwords are already not stored in the MRU, and correctly configured public machines will not even save the username.
<input type="password" placeholder="Enter New Password" autocomplete="new-password">
Here you go.
Read also this answer where he is using this easy solution that works everywhere (see also the fix for Safari mobile):
<input type="password" readonly onfocus="this.removeAttribute('readonly');"/>
You can use JQuery, select the item by id:
$("input#Password").attr("autocomplete","off");
Or select the item by type:
$("input[type='password']").attr("autocomplete","off");
Or also:
You can use pure Javascript:
document.getElementById('Password').autocomplete = 'off';
seeing as autocomplete=off is deprecated, I suggest a more recent solution.
Set your password field to a normal text field, and mask your input with "discs" using CSS. the code should look like this:
<input type="text" class="myPassword" />
input .myPassword{
text-security:disc;
-webkit-text-security:disc;
-mox-text-security:disc;
}
Please note that this may not work propely on firefox browsers, and an additional walkaround is needed. Read more about it here :https://stackoverflow.com/a/49304708/5477548.
The solution was taken from this link, but to comply with SO "no-hotlinks" i summarized it here.
you can use this: autocomplete="new-password"
Example:
<input type="password" placeholder="Enter New Password" autocomplete="new-password">