<p>One of the joys of working for a government healthcare agency is having to deal with all of the paranoia around dealing with PHI (Protected Health Information). Don't get me wrong, I'm all for doing everything possible to protect people's personal information (health, financial, surfing habits, etc.), but sometimes people get a little too jumpy.</p>

<p>Case in point: One of our state customers recently found out that the browser provides the handy feature to save your password. We all know that it has been there for a while and is completely optional and is up to the end user to decide whether or not it is a smart decision to use or not. However, there is a bit of an uproar at the moment and we are being demanded to find a way to disable that functionality for our site.</p>

<p><strong>Question</strong>: Is there a way for a site to tell the browser not to offer to remember passwords? I've been around web development a long time but don't know that I have come across that before.</p>

<p>Any help is appreciated.</p>

[{'answer_id': 32378, 'author': 'Jason Bunting', 'author_id': 1790, 'author_profile': 'https://Stackoverflow.com/users/1790', 'pm_score': 3, 'selected': False, 'text': '<p>Not really - the only thing you could realistically do is offer advice on the site; maybe, before their first time signing in, you could show them a form with information indicating that it is not recommended that they allow the browser to store the password.</p>\n\n<p>Then the user will immediately follow the advice, write down the password on a post-it note and tape it to their monitor.</p>\n'}, {'answer_id': 32386, 'author': 'Markus Olsson', 'author_id': 2114, 'author_profile': 'https://Stackoverflow.com/users/2114', 'pm_score': 9, 'selected': True, 'text': '<p>I\'m not sure if it\'ll work in all browsers but you should try setting autocomplete=&quot;off&quot; on the form.</p>\n<pre><code>&lt;form id=&quot;loginForm&quot; action=&quot;login.cgi&quot; method=&quot;post&quot; autocomplete=&quot;off&quot;&gt;\n</code></pre>\n<blockquote>\n<p>The easiest and simplest way to disable Form <strong>and Password storage prompts</strong> and prevent form data from being cached in session history is to use the autocomplete form element attribute with value &quot;off&quot;.</p>\n</blockquote>\n<blockquote>\n<p>From <a href="https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion" rel="noreferrer">https://developer.mozilla.org/en-US/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion</a></p>\n</blockquote>\n<p>Some minor research shows that this works in IE to but I\'ll leave no guarantees ;)</p>\n<p><a href="https://stackoverflow.com/questions/32369/disable-browser-save-password-functionality#32408">@Joseph</a>: If it\'s a strict requirement to pass XHTML validation with the actual markup (don\'t know why it would be though) you could theoretically add this attribute with javascript afterwards but then users with js disabled (probably a neglectable amount of your userbase or zero if your site requires js) will still have their passwords saved.</p>\n<p>Example with jQuery:</p>\n<pre><code>$(\'#loginForm\').attr(\'autocomplete\', \'off\');\n</code></pre>\n'}, {'answer_id': 32388, 'author': 'Joseph Pecoraro', 'author_id': 792, 'author_profile': 'https://Stackoverflow.com/users/792', 'pm_score': -1, 'selected': False, 'text': '<blockquote>\n  <p>Is there a way for a site to tell the browser not to offer to remember passwords?</p>\n</blockquote>\n\n<p>The website tells the browser that it is a password by using <code>&lt;input type="password"&gt;</code>.  So if you <em>must</em> do this from a website perspective then you would have to change that.  (Obviously I don\'t recommend this).</p>\n\n<p>The best solution would be to have the user configure their browser so it won\'t remember passwords.</p>\n'}, {'answer_id': 32390, 'author': 'Huppie', 'author_id': 1830, 'author_profile': 'https://Stackoverflow.com/users/1830', 'pm_score': 0, 'selected': False, 'text': '<p>One way I know is to use (for instance) JavaScript to copy the value out of the password field before submitting the form.</p>\n\n<p>The main problem with this is that the solution is tied to JavaScript.</p>\n\n<p>Then again, if it can be tied to JavaScript you might as well hash the password on the client-side before sending a request to the server.</p>\n'}, {'answer_id': 32408, 'author': 'Joseph Pecoraro', 'author_id': 792, 'author_profile': 'https://Stackoverflow.com/users/792', 'pm_score': 1, 'selected': False, 'text': '<p>Markus raised a great point.  I decided to look up the <code>autocomplete</code> attribute and got the following: </p>\n\n<blockquote>\n  <p>The only downside to using this\n  attribute is that it is not standard\n  (it works in IE and Mozilla browsers),\n  and would cause XHTML validation to\n  fail. I think this is a case where\n  it\'s reasonable to break validation\n  however.  <em>(<a href="http://www.petefreitag.com/item/481.cfm" rel="nofollow noreferrer">source</a>)</em></p>\n</blockquote>\n\n<p>So I would have to say that although it doesn\'t work 100% across the board it is handled in the major browsers so its a great solution.</p>\n'}, {'answer_id': 32409, 'author': 'Joel Coehoorn', 'author_id': 3043, 'author_profile': 'https://Stackoverflow.com/users/3043', 'pm_score': 4, 'selected': False, 'text': "<p>You can prevent the browser from matching the forms up by randomizing the name used for the password field on each show.  Then the browser sees a password for the same the url, but can't be sure it's the <em>same password</em>.  Maybe it's controlling something else.</p>\n<p><strong>Update:</strong> note that this should be <em>in addition to</em> using autocomplete or other tactics, not a replacement for them, for the reasons indicated by others.</p>\n<p>Also note that this will only prevent the browser from <em>auto-completing</em> the password. It won't prevent it from <em>storing</em> the password in whatever level of arbitrary security the browser chooses to use.</p>\n"}, {'answer_id': 380647, 'author': 'David Schmitt', 'author_id': 4918, 'author_profile': 'https://Stackoverflow.com/users/4918', 'pm_score': 4, 'selected': False, 'text': '<p>Use real <a href="http://en.wikipedia.org/wiki/Two-factor_authentication" rel="noreferrer">two-factor authentication</a> to avoid the sole dependency on passwords which might be stored in many more places than the user\'s browser cache.</p>\n'}, {'answer_id': 2359480, 'author': 'Howard Young', 'author_id': 283958, 'author_profile': 'https://Stackoverflow.com/users/283958', 'pm_score': 3, 'selected': False, 'text': '<p>What I have been doing is a combination of autocomplete="off" and clearing password fields using a javascript / jQuery.</p>\n\n<p>jQuery Example:</p>\n\n<pre><code>$(function() { \n    $(\'#PasswordEdit\').attr("autocomplete", "off");\n    setTimeout(\'$("#PasswordEdit").val("");\', 50); \n});\n</code></pre>\n\n<p>By using <code>setTimeout()</code> you can wait for the browser to complete the field before you clear it, otherwise the browser will always autocomplete after you\'ve clear the field.</p>\n'}, {'answer_id': 2555771, 'author': 'Mike Stone', 'author_id': 122, 'author_profile': 'https://Stackoverflow.com/users/122', 'pm_score': 5, 'selected': False, 'text': '<p>I had been struggling with this problem a while, with a unique twist to the problem.  Privileged users couldn\'t have the saved passwords work for them, but normal users needed it.  This meant privileged users had to log in twice, the second time enforcing no saved passwords.</p>\n\n<p>With this requirement, the standard <code>autocomplete="off"</code> method doesn\'t work across all browsers, because the password may have been saved from the first login.  A colleague found a solution to replace the password field when it was focused with a new password field, and then focus on the new password field (then hook up the same event handler).  This worked (except it caused an infinite loop in IE6).  Maybe there was a way around that, but it was causing me a migraine.</p>\n\n<p>Finally, I tried to just have the username and password outside of the form.  To my surprise, this worked!  It worked on IE6, and current versions of Firefox and Chrome on Linux.  I haven\'t tested it further, but I suspect it works in most if not all browsers (but it wouldn\'t surprise me if there was a browser out there that didn\'t care if there was no form).</p>\n\n<p>Here is some sample code, along with some jQuery to get it to work:</p>\n\n<pre><code>&lt;input type="text" id="username" name="username"/&gt;\n&lt;input type="password" id="password" name="password"/&gt;\n\n&lt;form id="theForm" action="/your/login" method="post"&gt;\n  &lt;input type="hidden" id="hiddenUsername" name="username"/&gt;\n  &lt;input type="hidden" id="hiddenPassword" name="password"/&gt;\n  &lt;input type="submit" value="Login"/&gt;\n&lt;/form&gt;\n\n&lt;script type="text/javascript" language="JavaScript"&gt;\n  $("#theForm").submit(function() {\n    $("#hiddenUsername").val($("#username").val());\n    $("#hiddenPassword").val($("#password").val());\n  });\n  $("#username,#password").keypress(function(e) {\n    if (e.which == 13) {\n      $("#theForm").submit();\n    }\n  });\n&lt;/script&gt;\n</code></pre>\n'}, {'answer_id': 4917668, 'author': 'Thrawn', 'author_id': 605867, 'author_profile': 'https://Stackoverflow.com/users/605867', 'pm_score': 2, 'selected': False, 'text': "<p>Just so people realise - the 'autocomplete' attribute works most of the time, but power users can get around it using a bookmarklet.</p>\n\n<p>Having a browser save your passwords actually increases protection against keylogging, so possibly the safest option is to save passwords in the browser but protect them with a master password (at least in Firefox).</p>\n"}, {'answer_id': 5676880, 'author': 'Peter Nelson', 'author_id': 709813, 'author_profile': 'https://Stackoverflow.com/users/709813', 'pm_score': -1, 'selected': False, 'text': '<p>autocomplete="off" works for most modern browsers, but another method I used that worked successfully with Epiphany (a WebKit-powered browser for GNOME) is to store a randomly generated prefix in session state (or a hidden field, I happened to have a suitable variable in session state already), and use this to alter the name of the fields. Epiphany still wants to save the password, but when going back to the form it won\'t populate the fields.</p>\n'}, {'answer_id': 10305547, 'author': 'Spechal', 'author_id': 427387, 'author_profile': 'https://Stackoverflow.com/users/427387', 'pm_score': -1, 'selected': False, 'text': '<p>I haven\'t had any issues using this method:</p>\n\n<p>Use autocomplete="off", add a hidden password field and then another non-hidden one.  The browser tries to auto complete the hidden one if it doesn\'t respect autocomplete="off"</p>\n'}, {'answer_id': 10853609, 'author': 'Tom', 'author_id': 1431092, 'author_profile': 'https://Stackoverflow.com/users/1431092', 'pm_score': -1, 'selected': False, 'text': '<p>If you do not want to trust the autocomplete flag, you can make sure that the user types in the box using the onchange event. The code below is a simple HTML form. The hidden form element password_edited starts out set to 0. When the value of password is changed, the JavaScript at the top (pw_edited function) changes the value to 1. When the button is pressed, it checks the valueenter code here before submitting the form. That way, even if the browser ignores you and autocompletes the field, the user cannot pass the login page without typing in the password field. Also, make sure to blank the password field when focus is set. Otherwise, you can add a character at the end, then go back and remove it to trick the system. I recommend adding the autocomplete="off" to password in addition, but this example shows how the backup code works.</p>\n\n<pre><code>&lt;html&gt;\n  &lt;head&gt;\n    &lt;script&gt;\n      function pw_edited() {\n        document.this_form.password_edited.value = 1;\n      }\n      function pw_blank() {\n        document.this_form.password.value = "";\n      }\n      function submitf() {\n        if(document.this_form.password_edited.value &lt; 1) {\n          alert("Please Enter Your Password!");\n        }\n        else {\n         document.this_form.submit();\n        }\n      }\n    &lt;/script&gt;\n  &lt;/head&gt;\n  &lt;body&gt;\n    &lt;form name="this_form" method="post" action="../../cgi-bin/yourscript.cgi?login"&gt;\n      &lt;div style="padding-left:25px;"&gt;\n        &lt;p&gt;\n          &lt;label&gt;User:&lt;/label&gt;\n          &lt;input name="user_name" type="text" class="input" value="" size="30" maxlength="60"&gt;\n        &lt;/p&gt;\n        &lt;p&gt;\n          &lt;label&gt;Password:&lt;/label&gt;\n          &lt;input name="password" type="password" class="input" size="20" value="" maxlength="50" onfocus="pw_blank();" onchange="pw_edited();"&gt;\n        &lt;/p&gt;\n        &lt;p&gt;\n          &lt;span id="error_msg"&gt;&lt;/span&gt;\n        &lt;/p&gt;\n        &lt;p&gt;\n          &lt;input type="hidden" name="password_edited" value="0"&gt;\n          &lt;input name="submitform" type="button" class="button" value="Login" onclick="return submitf();"&gt;\n        &lt;/p&gt;\n      &lt;/div&gt;\n    &lt;/form&gt;\n  &lt;/body&gt;\n&lt;/html&gt;\n</code></pre>\n'}, {'answer_id': 11141892, 'author': 'Marcelo Finki', 'author_id': 996605, 'author_profile': 'https://Stackoverflow.com/users/996605', 'pm_score': -1, 'selected': False, 'text': '<p>IMHO,<br/>\nThe best way is to randomize the name of the input field that has <code>type=password</code>.\nUse a prefix of "pwd" and then a random number.\nCreate the field dynamically and present the form to the user.</p>\n\n<p>Your log-in form will look like...</p>\n\n<pre><code>&lt;form&gt;\n   &lt;input type=password id=pwd67584 ...&gt;\n   &lt;input type=text id=username ...&gt;\n   &lt;input type=submit&gt;\n&lt;/form&gt;\n</code></pre>\n\n<p>Then, on the server side, when you analyze the form posted by the client, catch the field with a name that starts with "pwd" and use it as \'password\'.</p>\n'}, {'answer_id': 14733402, 'author': 'Lord of the Goo', 'author_id': 277389, 'author_profile': 'https://Stackoverflow.com/users/277389', 'pm_score': -1, 'selected': False, 'text': '<p>Another solution is to make the POST using an hidden form where all the input are of type hidden. The visible form will use input of type "password". The latter form will never be submitted and so the browser can\'t intercept at all the operation of login.</p>\n'}, {'answer_id': 19223143, 'author': 'venimus', 'author_id': 623288, 'author_profile': 'https://Stackoverflow.com/users/623288', 'pm_score': 4, 'selected': False, 'text': '<p>The cleanest way is to use <code>autocomplete="off"</code> tag attribute but\nFirefox does not properly obey it when you switch fields with Tab.</p>\n\n<p>The only way you could stop this is to add a fake hidden password field which tricks the browser to populate the password there.</p>\n\n<pre><code>&lt;input type="text" id="username" name="username"/&gt;\n&lt;input type="password" id="prevent_autofill" autocomplete="off" style="display:none" tabindex="-1" /&gt;\n&lt;input type="password" id="password" autocomplete="off" name="password"/&gt;\n</code></pre>\n\n<p>It is an ugly hack, because you change the browser behavior, which should be considered bad practice. Use it only if you really need it.</p>\n\n<p>Note: this will effectively stop password autofill, because FF will "save" the value of <code>#prevent_autofill</code> (which is empty) and will try to populate any saved passwords there, as it always uses the first <code>type="password"</code> input it finds in DOM after the respective "username" input.</p>\n'}, {'answer_id': 20968859, 'author': 'Biau', 'author_id': 3168622, 'author_profile': 'https://Stackoverflow.com/users/3168622', 'pm_score': -1, 'selected': False, 'text': '<p>i think by putting autocomplete="off" does not help at all</p>\n\n<p>i have alternative solution,</p>\n\n<pre><code>&lt;input type="text" name="preventAutoPass" id="preventAutoPass" style="display:none" /&gt;\n</code></pre>\n\n<p>add this before your password input. </p>\n\n<p>eg:<code>&lt;input type="text" name="txtUserName" id="txtUserName" /&gt;\n&lt;input type="text" name="preventAutoPass" id="preventAutoPass" style="display:none" /&gt;\n&lt;input type="password" name="txtPass" id="txtPass" autocomplete="off" /&gt;</code></p>\n\n<p>this does not prevent browser ask and save the password. but it prevent the password to be filled in.</p>\n\n<p>cheer</p>\n'}, {'answer_id': 22215004, 'author': 'JW Lim', 'author_id': 3155705, 'author_profile': 'https://Stackoverflow.com/users/3155705', 'pm_score': -1, 'selected': False, 'text': '<p>Since Internet Explorer 11 no longer supports <code>autocomplete="off"</code> for <code>input type="password"</code> fields (hopefully no other browsers will follow their lead), the cleanest approach (at the time of writing) seems to be making users submit their username and password in different pages, i.e. the user enters their username, submit, then enters their password and submit. The <a href="https://www.bankofamerica.com/" rel="nofollow noreferrer">Bank Of America</a> and <a href="https://www.us.hsbc.com/1/2/home/personal-banking" rel="nofollow noreferrer">HSBC Bank</a> websites are using this, too.</p>\n\n<p>Because the browser is unable to associate the password with a username, it will not offer to store passwords. This approach works in all major browsers (at the time of writing) and will function properly without the use of Javascript. The downsides are that it would be more troublesome for the user, and would take 2 postbacks for a login action instead of one, so it really depends on how secure your website needs to be.</p>\n\n<p>Update: As mentioned in this <a href="https://stackoverflow.com/questions/32369/disable-browser-save-password-functionality/22215004#comment36051950_32386">comment</a> by <a href="https://stackoverflow.com/users/119975/gregory-cosmo-haun">Gregory</a>, Firefox will be following IE11\'s lead and ignore <code>autocomplete="off"</code> for password fields.</p>\n'}, {'answer_id': 23927796, 'author': 'Asik', 'author_id': 1387002, 'author_profile': 'https://Stackoverflow.com/users/1387002', 'pm_score': 4, 'selected': False, 'text': '<p>I have tested that adding autocomplete="off" in form tag in all major browsers. In fact, Most of the peoples in US using IE8 so far.</p>\n\n<ol>\n<li>IE8, IE9, IE10, Firefox, Safari are works fine. \n\n<blockquote>\n  <p>Browser not asking "save password". \n  Also, previously saved username &amp; password not populated.</p>\n</blockquote></li>\n<li>Chrome &amp; IE 11 not supporting the autocomplete="off" feature</li>\n<li>FF supporting the autocomplete="off". but sometimes existing saved\ncredentials are populated.</li>\n</ol>\n\n<p><strong>Updated on June 11, 2014</strong></p>\n\n<p>Finally, below is a cross browser solution using javascript and it is working fine in all browsers.</p>\n\n<p>Need to remove "form" tag in login form. After client side validation, put that credentials in hidden form and submit it.</p>\n\n<p>Also, add two methods. one for validation "validateLogin()" and another for listening enter event while click enter in textbox/password/button "checkAndSubmit()". because now login form does not have a form tag, so enter event not working here.</p>\n\n<p><strong>HTML</strong></p>\n\n<pre><code>&lt;form id="HiddenLoginForm" action="" method="post"&gt;\n&lt;input type="hidden" name="username" id="hidden_username" /&gt;\n&lt;input type="hidden" name="password" id="hidden_password" /&gt;\n&lt;/form&gt;\n\nUsername: &lt;input type="text" name="username" id="username" onKeyPress="return checkAndSubmit(event);" /&gt; \nPassword: &lt;input type="text" name="password" id="password" onKeyPress="return checkAndSubmit(event);" /&gt; \n&lt;input type="button" value="submit" onClick="return validateAndLogin();" onKeyPress="return checkAndSubmit(event);" /&gt; \n</code></pre>\n\n<p><strong>Javascript</strong></p>\n\n<pre><code>//For validation- you can modify as you like\nfunction validateAndLogin(){\n  var username = document.getElementById("username");\n  var password = document.getElementById("password");\n\n  if(username  &amp;&amp; username.value == \'\'){\n    alert("Please enter username!");\n    return false;\n  }\n\n  if(password &amp;&amp; password.value == \'\'){\n    alert("Please enter password!");\n    return false;\n  }\n\n  document.getElementById("hidden_username").value = username.value;\n  document.getElementById("hidden_password").value = password.value;\n  document.getElementById("HiddenLoginForm").submit();\n}\n\n//For enter event\nfunction checkAndSubmit(e) {\n if (e.keyCode == 13) {\n   validateAndLogin();\n }\n}\n</code></pre>\n\n<p>Good luck!!!</p>\n'}, {'answer_id': 24428343, 'author': 'ruruskyi', 'author_id': 372939, 'author_profile': 'https://Stackoverflow.com/users/372939', 'pm_score': 1, 'selected': False, 'text': '<p>The real problem is much deeper than just adding attributes to your HTML - this is common security concern, that\'s why people invented hardware keys and other crazy things for security. </p>\n\n<p>Imagine you have autocomplete="off" perfectly working in all browsers. Would that help with security? Of course, no. Users will write down their passwords in textbooks, on stickers attached to their monitor where every office visitor can see them, save them to text files on the desktop and so on.</p>\n\n<p>Generally, web application and web developer isn\'t responsible in any way for end-user security. End-users can protect themselves only. Ideally, they MUST keep all passwords in their head and use password reset functionality (or contact administrator) in case they forgot it. Otherwise there always will be a risk that password can be seen and stolen somehow.</p>\n\n<p>So either you have some crazy security policy with hardware keys (like, some banks offer for Internet-banking which basically employs two-factor authentication) or NO SECURITY basically. Well, this is a bit over exaggerated of course. It\'s important to understand what are you trying to protect against:</p>\n\n<ol>\n<li>Not authorised access. Simplest login form is enough basically. There sometimes additional measures taken like random security questions, CAPTCHAs, password hardening etc.</li>\n<li>Credential sniffing. HTTPS is A MUST if people access your web application from public Wi-Fi hotspots etc. Mention that even having HTTPS, your users need to change their passwords regularly. </li>\n<li>Insider attack. There are two many examples of such, starting from simple stealing of your passwords from browser or those that you have written down somewhere on the desk (does not require any IT skills) and ending with session forging and intercepting local network traffic (even encrypted) and further accessing web application just like it was another end-user.</li>\n</ol>\n\n<p>In this particular post, I can see inadequate requirements put on developer which he will never be able to resolve due to the nature of the problem - end-user security. My subjective point is that developer should basically say NO and point on requirement problem rather than wasting time on such tasks, honestly. This does not absolutely make your system more secure, it will rather lead to the cases with stickers on monitors. Unfortunately, some bosses hear only what they want to hear. However, if I was you I would try to explain where the actual problem is coming from, and that autocomplete="off" would not resolve it unless it will force users to keep all their passwords exclusively in their head! Developer on his end cannot protect users completely, users need to know how to use system and at the same time do not expose their sensitive/secure information and this goes far beyond authentication. </p>\n'}, {'answer_id': 24570452, 'author': 'Nikhil Dinesh', 'author_id': 735597, 'author_profile': 'https://Stackoverflow.com/users/735597', 'pm_score': 2, 'selected': False, 'text': '<p>if autocomplete="off" is not working...remove the form tag and use a div tag instead, then pass the form values using jquery to the server. This worked for me.</p>\n'}, {'answer_id': 24955110, 'author': 'Dai Bok', 'author_id': 198762, 'author_profile': 'https://Stackoverflow.com/users/198762', 'pm_score': 2, 'selected': False, 'text': '<p>I have a work around, which may help. </p>\n\n<p>You could make a custom font hack. So, make a custom font, with all the characters as a dot / circle / star for example. Use this as a custom font for your website. Check how to do this in inkscape: <a href="http://www.youtube.com/watch?v=_KX-e6sijGE" rel="nofollow">how to make your own font</a></p>\n\n<p>Then on your log in form use:</p>\n\n<pre><code>&lt;form autocomplete=\'off\'  ...&gt;\n   &lt;input type="text" name="email" ...&gt;\n   &lt;input type="text" name="password" class="password" autocomplete=\'off\' ...&gt;\n   &lt;input type=submit&gt;\n&lt;/form&gt;\n</code></pre>\n\n<p>Then add your css:</p>\n\n<pre><code>@font-face {\n    font-family: \'myCustomfont\';\n    src: url(\'myCustomfont.eot\');\n    src: url(\'myCustomfont?#iefix\') format(\'embedded-opentype\'),\n         url(\'myCustomfont.woff\') format(\'woff\'),\n         url(\'myCustomfont.ttf\') format(\'truetype\'),\n         url(\'myCustomfont.svg#myCustomfont\') format(\'svg\');\n    font-weight: normal;\n    font-style: normal;\n\n}\n.password {\n  font-family:\'myCustomfont\';\n}\n</code></pre>\n\n<p>Pretty cross browser compatible. I have tried IE6+, FF, Safari and Chrome. Just make sure that the oet font that you convert does not get corrupted. Hope it helps?</p>\n'}, {'answer_id': 25111774, 'author': 'whyAto8', 'author_id': 1122463, 'author_profile': 'https://Stackoverflow.com/users/1122463', 'pm_score': 5, 'selected': False, 'text': '<p>Well, its a very old post, but still I will give my solution, which my team had been trying to achieve for long. We just added a new input type="password" field inside the form and wrapped it in div and made the div hidden. Made sure that this div is before the actual password input. \nThis worked for us and it didn\'t gave any Save Password option</p>\n\n<p>Plunk - <a href="http://plnkr.co/edit/xmBR31NQMUgUhYHBiZSg?p=preview">http://plnkr.co/edit/xmBR31NQMUgUhYHBiZSg?p=preview</a> </p>\n\n<p>HTML:</p>\n\n<pre><code>&lt;form method="post" action="yoururl"&gt;\n      &lt;div class="hidden"&gt;\n        &lt;input type="password"/&gt;\n      &lt;/div&gt;\n      &lt;input type="text" name="username" placeholder="username"/&gt;\n      &lt;input type="password" name="password" placeholder="password"/&gt;\n    &lt;/form&gt;\n</code></pre>\n\n<p>CSS:</p>\n\n<pre><code>.hidden {display:none;}\n</code></pre>\n'}, {'answer_id': 25198684, 'author': 'Naradana', 'author_id': 1555826, 'author_profile': 'https://Stackoverflow.com/users/1555826', 'pm_score': -1, 'selected': False, 'text': '<p>autocomplete="off" does not work for disabling the password manager in Firefox 31 and most likely not in some earlier versions, too.</p>\n\n<p>Checkout the discussion at mozilla about this issue:\n<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=956906" rel="nofollow">https://bugzilla.mozilla.org/show_bug.cgi?id=956906</a></p>\n\n<p>We wanted to use a second password field to enter a one-time password generated by a token. Now we are using a text input instead of a password input. :-(</p>\n'}, {'answer_id': 31655148, 'author': 'Sheiky', 'author_id': 3732989, 'author_profile': 'https://Stackoverflow.com/users/3732989', 'pm_score': -1, 'selected': False, 'text': '<p>I was given a similar task to disable the auto-filling up of login name and passwords by browser, after lot of trial and errors i found the below solution to be optimal. Just add the below controls before your original controls.</p>\n\n<pre><code>&lt;input type="text" style="display:none"&gt;\n&lt;input type="text" name="OriginalLoginTextBox"&gt;\n\n&lt;input type="password" style="display:none"&gt;\n&lt;input type="text" name="OriginalPasswordTextBox"&gt;\n</code></pre>\n\n<p>This is working fine for IE11 and Chrome 44.0.2403.107 </p>\n'}, {'answer_id': 31813922, 'author': 'knee-cola', 'author_id': 268905, 'author_profile': 'https://Stackoverflow.com/users/268905', 'pm_score': 2, 'selected': False, 'text': '<p>The simplest way to solve this problem is to place INPUT fields outside the FORM tag and add two hidden fields inside the FORM tag. Then in a submit event listener before the form data gets submitted to server copy values from visible input to the invisible ones.</p>\n\n<p>Here\'s an example (you can\'t run it here, since the form action is not set to a real login script):</p>\n\n<p><div class="snippet" data-lang="js" data-hide="false">\r\n<div class="snippet-code">\r\n<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!doctype html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n  &lt;title&gt;Login &amp; Save password test&lt;/title&gt;\r\n  &lt;meta charset="utf-8"&gt;\r\n  &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"&gt;&lt;/script&gt;\r\n&lt;/head&gt;\r\n\r\n  &lt;body&gt;\r\n      &lt;!-- the following fields will show on page, but are not part of the form --&gt;\r\n      &lt;input class="username" type="text" placeholder="Username" /&gt;\r\n      &lt;input class="password" type="password" placeholder="Password" /&gt;\r\n\r\n      &lt;form id="loginForm" action="login.aspx" method="post"&gt;\r\n        &lt;!-- thw following two fields are part of the form, but are not visible --&gt;\r\n        &lt;input name="username" id="username" type="hidden" /&gt;\r\n        &lt;input name="password" id="password" type="hidden" /&gt;\r\n        &lt;!-- standard submit button --&gt;\r\n        &lt;button type="submit"&gt;Login&lt;/button&gt;\r\n      &lt;/form&gt;\r\n\r\n    &lt;script&gt;\r\n      // attache a event listener which will get called just before the form data is sent to server\r\n      $(\'form\').submit(function(ev) {\r\n        console.log(\'xxx\');\r\n        // read the value from the visible INPUT and save it to invisible one\r\n        // ... so that it gets sent to the server\r\n        $(\'#username\').val($(\'.username\').val());\r\n        $(\'#password\').val($(\'.password\').val());\r\n      });\r\n    &lt;/script&gt;\r\n\r\n  &lt;/body&gt;\r\n&lt;/html&gt;</code></pre>\r\n</div>\r\n</div>\r\n</p>\n'}, {'answer_id': 32281293, 'author': 'ovalek', 'author_id': 1102219, 'author_profile': 'https://Stackoverflow.com/users/1102219', 'pm_score': 2, 'selected': False, 'text': '<p>My js (jquery) workaround is to <strong>change password input type to text on form submit</strong>. The password could become visible for a second, so I also hide the input just before that. <strong>I would rather not use this for login forms</strong>, but it is useful (together with autocomplete="off") for example inside administration part of the website.</p>\n\n<p>Try putting this inside a console (with jquery), before you submit the form.</p>\n\n<pre class="lang-js prettyprint-override"><code>$(\'form\').submit(function(event) {\n    $(this).find(\'input[type=password]\').css(\'visibility\', \'hidden\').attr(\'type\', \'text\');\n});\n</code></pre>\n\n\n\n<p>Tested on Chrome 44.0.2403.157 (64-bit).</p>\n'}, {'answer_id': 36073643, 'author': 'Mike', 'author_id': 4240993, 'author_profile': 'https://Stackoverflow.com/users/4240993', 'pm_score': 0, 'selected': False, 'text': '<p>Facing the same HIPAA issue and found a relatively easy solution,</p>\n\n<ol>\n<li><p>Create a hidden password field with the field name as an array.</p>\n\n<pre><code>&lt;input type="password" name="password[]" style="display:none" /&gt;\n</code></pre></li>\n<li><p>Use the same array for the actual password field.</p>\n\n<pre><code>&lt;input type="password" name="password[]" /&gt;\n</code></pre></li>\n</ol>\n\n<p>The browser (Chrome) may prompt you to "Save password" but regardless if the user selects save, the next time they login the password will auto-populate the hidden password field, the zero slot in the array, leaving the 1st slot blank.</p>\n\n<p>I tried defining the array, such as "password[part2]" but it still remembered. I think it throws it off if it\'s an unindexed array because it has no choice but to drop it in the first spot.</p>\n\n<p>Then you use your programming language of choice to access the array, PHP for example,</p>\n\n<pre><code>echo $_POST[\'password\'][1];\n</code></pre>\n'}, {'answer_id': 37292424, 'author': 'Murat Yıldız', 'author_id': 1604048, 'author_profile': 'https://Stackoverflow.com/users/1604048', 'pm_score': 6, 'selected': False, 'text': '<blockquote>\n  <p>In addition to</p>\n</blockquote>\n\n<pre><code>autocomplete="off"\n</code></pre>\n\n<blockquote>\n  <p>Use</p>\n</blockquote>\n\n<pre><code>readonly onfocus="this.removeAttribute(\'readonly\');"\n</code></pre>\n\n<p>for the inputs that you do not want them to remember form data (<code>username</code>, <code>password</code>, etc.) as shown below: </p>\n\n<pre><code>&lt;input type="text" name="UserName" autocomplete="off" readonly \n    onfocus="this.removeAttribute(\'readonly\');" &gt;\n\n&lt;input type="password" name="Password" autocomplete="off" readonly \n    onfocus="this.removeAttribute(\'readonly\');" &gt;\n</code></pre>\n\n<p>Tested on the latest versions of the major browsers i.e. <code>Google Chrome</code>, <code>Mozilla Firefox</code>, <code>Microsoft Edge</code>, etc. and works like a charm. Hope this helps.</p>\n'}, {'answer_id': 42929645, 'author': 'Lasitha Benaragama', 'author_id': 853671, 'author_profile': 'https://Stackoverflow.com/users/853671', 'pm_score': 1, 'selected': False, 'text': '<p>I tried above <code>autocomplete="off"</code> and yet anything successful. if you are using angular js my recommendation is to go with button and the ng-click. </p>\n\n<pre><code>&lt;button type="button" class="" ng-click="vm.login()" /&gt;\n</code></pre>\n\n<p>This already have a accepted answer im adding this if someone cant solve the problem with the accepted answer he can go with my mechanism. </p>\n\n<p>Thanks for the question and the answers. </p>\n'}, {'answer_id': 43206336, 'author': 'mfernandes', 'author_id': 1892887, 'author_profile': 'https://Stackoverflow.com/users/1892887', 'pm_score': 2, 'selected': False, 'text': '<p>Because autocomplete="off" does not work for password fields, one must rely on javascript. Here\'s a simple solution based on answers found here.</p>\n\n<p>Add the attribute data-password-autocomplete="off" to your password field:</p>\n\n<pre><code>&lt;input type="password" data-password-autocomplete="off"&gt;\n</code></pre>\n\n<p>Include the following JS:</p>\n\n<pre><code>$(function(){\n    $(\'[data-password-autocomplete="off"]\').each(function() {\n        $(this).prop(\'type\', \'text\');\n        $(\'&lt;input type="password"/&gt;\').hide().insertBefore(this);\n        $(this).focus(function() {\n            $(this).prop(\'type\', \'password\');\n        });\n    });     \n});\n</code></pre>\n\n<p>This solution  works for both Chrome and FF.</p>\n'}, {'answer_id': 43353829, 'author': 'Cedric Simon', 'author_id': 2838910, 'author_profile': 'https://Stackoverflow.com/users/2838910', 'pm_score': 2, 'selected': False, 'text': '<p>I tested lots of solutions. Dynamic password field name, multiple password fields (invisible for fake ones), changing input type from "text" to "password", autocomplete="off", autocomplete="new-password",... but nothing solved it with recent browser.</p>\n\n<p>To get rid of password remember, I finally treated the password as input field, and "blur" the text typed. </p>\n\n<p>It is less "safe" than a native password field since selecting the typed text would show it as clear text, but password is not remembered. It also depends on having Javascript activated.</p>\n\n<p>You will have estimate the risk of using below proposal vs password remember option from navigator.</p>\n\n<p>While password remember can be managed (disbaled per site) by the user, it\'s fine for a personal computer, not for a "public" or shared computer.</p>\n\n<p>I my case it\'s for a ERP running on shared computers, so I\'ll give it a try to my solution below. </p>\n\n<pre><code>&lt;input style="background-color: rgb(239, 179, 196); color: black; text-shadow: none;" name="password" size="10" maxlength="30" onfocus="this.value=\'\';this.style.color=\'black\'; this.style.textShadow=\'none\';" onkeypress="this.style.color=\'transparent\'; this.style.textShadow=\'1px 1px 6px green\';" autocomplete="off" type="text"&gt;\n</code></pre>\n'}, {'answer_id': 49114022, 'author': 'CubicleSoft', 'author_id': 917198, 'author_profile': 'https://Stackoverflow.com/users/917198', 'pm_score': 0, 'selected': False, 'text': '<p>Since most of the <code>autocomplete</code> suggestions, including the accepted answer, don\'t work in today\'s web browsers (i.e. web browser password managers ignore <code>autocomplete</code>), a more novel solution is to swap between <code>password</code> and <code>text</code> types and make the background color match the text color when the field is a plain text field, which continues to hide the password while being a real password field when the user (or a program like KeePass) is entering a password.  Browsers don\'t ask to save passwords that are stored in plain text fields.</p>\n\n<p>The advantage of this approach is that it allows for progressive enhancement and therefore doesn\'t require Javascript for a field to function as a normal password field (you could also start with a plain text field instead and apply the same approach but that\'s not really HIPAA PHI/PII-compliant).  Nor does this approach depend on hidden forms/fields which might not necessarily be sent to the server (because they are hidden) and some of those tricks also don\'t work either in several modern browsers.</p>\n\n<p>jQuery plugin:</p>\n\n<p><a href="https://github.com/cubiclesoft/php-flexforms-modules/blob/master/password-manager/jquery.stoppasswordmanager.js" rel="nofollow noreferrer">https://github.com/cubiclesoft/php-flexforms-modules/blob/master/password-manager/jquery.stoppasswordmanager.js</a></p>\n\n<p>Relevant source code from the above link:</p>\n\n<pre><code>(function($) {\n$.fn.StopPasswordManager = function() {\n    return this.each(function() {\n        var $this = $(this);\n\n        $this.addClass(\'no-print\');\n        $this.attr(\'data-background-color\', $this.css(\'background-color\'));\n        $this.css(\'background-color\', $this.css(\'color\'));\n        $this.attr(\'type\', \'text\');\n        $this.attr(\'autocomplete\', \'off\');\n\n        $this.focus(function() {\n            $this.attr(\'type\', \'password\');\n            $this.css(\'background-color\', $this.attr(\'data-background-color\'));\n        });\n\n        $this.blur(function() {\n            $this.css(\'background-color\', $this.css(\'color\'));\n            $this.attr(\'type\', \'text\');\n            $this[0].selectionStart = $this[0].selectionEnd;\n        });\n\n        $this.on(\'keydown\', function(e) {\n            if (e.keyCode == 13)\n            {\n                $this.css(\'background-color\', $this.css(\'color\'));\n                $this.attr(\'type\', \'text\');\n                $this[0].selectionStart = $this[0].selectionEnd;\n            }\n        });\n    });\n}\n}(jQuery));\n</code></pre>\n\n<p>Demo:</p>\n\n<p><a href="https://barebonescms.com/demos/admin_pack/admin.php" rel="nofollow noreferrer">https://barebonescms.com/demos/admin_pack/admin.php</a></p>\n\n<p>Click "Add Entry" in the menu and then scroll to the bottom of the page to "Module: Stop Password Manager".</p>\n\n<p>Disclaimer:  While this approach works for sighted individuals, there might be issues with screen reader software.  For example, a screen reader might read the user\'s password out loud because it sees a plain text field.  There might also be other unforeseen consequences of using the above plugin.  Altering built-in web browser functionality should be done sparingly with testing a wide variety of conditions and edge cases.</p>\n'}, {'answer_id': 64872142, 'author': 'Burak Ekincioğlu', 'author_id': 9559819, 'author_profile': 'https://Stackoverflow.com/users/9559819', 'pm_score': 2, 'selected': False, 'text': "<p>This is my html code for solution. <strong>It works for Chrome-Safari-Internet Explorer</strong>. I created new font which all characters seem as &quot;●&quot;. Then I use this font for my password text. Note: My font name is &quot;passwordsecretregular&quot;.</p>\n<pre><code>&lt;style type=&quot;text/css&quot;&gt;\n         #login_parola {\n             font-family: 'passwordsecretregular' !important;\n            -webkit-text-security: disc !important;\n            font-size: 22px !important;\n         }\n    &lt;/style&gt;\n\n\n&lt;input type=&quot;text&quot; class=&quot;w205 has-keyboard-alpha&quot;  name=&quot;login_parola&quot; id=&quot;login_parola&quot; onkeyup=&quot;checkCapsWarning(event)&quot;  \n   onfocus=&quot;checkCapsWarning(event)&quot; onblur=&quot;removeCapsWarning()&quot; onpaste=&quot;return false;&quot; maxlength=&quot;32&quot;/&gt;\n</code></pre>\n"}, {'answer_id': 73055897, 'author': 'Stu', 'author_id': 14274352, 'author_profile': 'https://Stackoverflow.com/users/14274352', 'pm_score': 0, 'selected': False, 'text': "<pre><code>&lt;input type=&quot;text&quot; id=&quot;mPassword&quot; required=&quot;required&quot; title=&quot;Valid password required&quot; autocomplete=&quot;off&quot; list=&quot;autocompleteOff&quot; readonly onfocus=&quot;this.removeAttribute('readonly');&quot; style=&quot;text-security:disc; -webkit-text-security:disc;&quot; oncopy=&quot;return false;&quot; onpaste=&quot;return false;&quot;/&gt;\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/32369', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3262/']