0

How do I disable browser save password functionality?

The suggestions from the same questions are no longer working since browsers chose not to support this any more. I don't really want to discuss whether this should be the case or not, just asking for the most simple way to trick browser into not showing send password window.

Community
  • 1
  • 1
Fluffy
  • 24,946
  • 33
  • 140
  • 221
  • Not sure but the answer given by Joel Coehoorn in this thread seems to be useful: http://stackoverflow.com/questions/32369/disable-browser-save-password-functionality – Rahul Tripathi Apr 21 '15 at 19:56

2 Answers2

2

Like many people, I used to use the autocomplete=off trick for years. Unfortunately, now that browsers are no longer supporting that attribute, I had to come up with something else. Here is a solution in jQuery that works:

$(function() {
    $('input[type=password]').each(function() {
        $(this).attr('data-background-color', $(this).css('background-color'));
        $(this).css('background-color', $(this).css('color'));
        $(this).attr('type', 'text');

        $(this).focus(function() {
            $(this).attr('type', 'password');
            $(this).css('background-color', $(this).attr('data-background-color'));
        });

        $(this).blur(function() {
            $(this).css('background-color', $(this).css('color'));
            $(this).attr('type', 'text');
        });
    });
});

It won't stop auto-completion, which is the intent of the change to autocomplete, but it will stop password storage managers from detecting a password field in the first place.

How it works: It grabs the background color of the text field after the page finishes loading and squirrels it away (data-background-color). Then it sets the background color to the text color and changes the input type to 'text'. On focus, the field is restored to its previous state (password field with original background color). On blur, the field background color and type are swapped out again. When submitting the form, it is just a text field. You get all the benefits of a password field (e.g. no copying) without a password manager to get in the way when submitting the form.

Notes: It might not work properly if there are special effects on the text itself. It also has some minor keyboard caret focus issues where clicking in the field causes the caret to jump to the beginning of the text instead of where the click took place.

On the plus side, it plays nice with browsers that have Javascript disabled. Progressive enhancement and all that.

maddog
  • 432
  • 3
  • 10
  • One caveat: After deploying into production, I discovered that this has one side-effect. Apparently iOS (and maybe other mobile OSes) will attempt to capitalize the first letter of the password. It's not horrible but it is annoying for those users. However, it is less annoying than having a password manager try to remember an irrelevant password or passwords it should not attempt to remember in the first place. Solution: Have affected users change their passwords so that the first letter is a capital letter. – maddog May 18 '16 at 22:24
-1

well you should use autocomplete Attribute

The autocomplete Attribute

The autocomplete attribute specifies whether a form or input field should have autocomplete on or off. When autocomplete is on, the browser automatically complete values based on values that the user has entered before.

Tip: It is possible to have autocomplete "on" for the form, and "off" for specific input fields, or vice versa.

The autocomplete attribute works with and the following types: text, search, url, tel, email, password, datepickers, range, and color.

 <form action="action_page.php" autocomplete="off">
  First name:<input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  E-mail: <input type="email" name="email" autocomplete="off"><br>
  <input type="submit">
</form> 

it is up to browser to respect if show up password save dialog box or not

hadi
  • 956
  • 6
  • 22