Disable Save Password in Chrome in JavaScript

7

Would there be any way to disable the password saving option in Google Chrome, by JavaScript or jQuery?

I mean the login password. When my client logs in he appears the option to save the password, and after he has enabled it, he always logs in when he logs on. I want to disable this in any Browser.

    
asked by anonymous 27.03.2014 / 16:13

5 answers

7

Reading the response from Markus Olsson in SOen, the suggestion is to use autocomplete of HTML to tell the browser not to write information:

<form id="loginForm" action="login.cgi" method="post" autocomplete="off">

You can read more documentation about this in MDN English . In this link you can read (freely translated):

  

The easiest and simplest way to disable questions to write Forms and Passwords and prevent data from being written is in the browser history cache is using the autocomplete attribute with the value "off. p>

Viewed

strong> IE11 has decided to break this rule and ignore this behavior.

There are two other hypotheses:

  • Make name of the input random. Generated from the server side and saved in SESSION for example.

  • Log in via Ajax and there instead of sending a form submit, would send the password and cleaned the field without the browser realizing.

27.03.2014 / 16:18
5
  

This is a companion and server-side response. I'm posting as an additional option.

     

Method advantage: it respects the autocomplete of the username, and only protects the password.

Using some server side language, you can change the name of the password field to a pseudo-random string, and use a hidden field to store that string, thus:

<input type="text" name="usuario">
<input type="password" name="SYG2d7s6f1Sr874yYGJ4">
<input type="hidden" name="auxiliar" value="SYG2d7s6f1Sr874yYGJ4">

So, the (practically) password field will never be the same, taking away the effectiveness of what was previously saved under another name.

Then, in a language like PHP, just use it like this:

$auxiliar=$_POST['auxiliar']

$usuario=$_POST['usuario']
$senha=$_POST[$auxiliar]

Another complementary trick is to create two fields of type password , some browsers understand this as probable form of password reset, and do not save in this case (you can hide one of them with CSS, for example).

    
28.03.2014 / 03:32
1

put the attribute autocomplete="off" I believe it's not all browsers that support it.

  

Documentation link

    
27.03.2014 / 16:17
1

Nothing of the above has worked, but I have created a simple solution.

Set the three inputs of the form, two of which are of type "text" and enter a javascript function in the password field that in my case I defined as "change ()" and a "hidden" field:

input name="usuario_login" **type="text"** id="usuario_login" required
autofocus/>

input name="senha" required **type="text"** id="senha" **onkeyup="trocar()"**/>

input type="hidden" name="senha_login" id="senha_login" value="" />

Below the javascript function that will replace the typed character in the password field with "*" and transfer the typed into the hidden field.

function trocar(){

  var tecla = event.keyCode;

  if(tecla == 8){

    document.getElementById('senha_login').value = document.getElementById('senha_login').value.substring(0 ,  document.getElementById('senha').value.length);

  }else{

    if(tecla != 9 & tecla != 13){

       document.getElementById('senha_login').value = document.getElementById('senha_login').value + document.getElementById('senha').value.charAt(document.getElementById('senha').value.length - 1);

       document.getElementById('senha').value = document.getElementById('senha').value.replace(document.getElementById('senha').value.charAt(document.getElementById('senha').value.length - 1), '*'); 

    } 
  }
}

Then just get the server language values "ASP", "PHP" or other and validate.

    
14.10.2018 / 14:27
-1

Basically, chrome recognizes any form with only two inputs (one text and another password) as a password field and writes whatever data the user types there. Then it suggests that you can save the data.

I recommend that you use two inputs of type password whenever you ask for password confirmation. This makes the browser confusing.

<input type='password' name='senha' />
<input type='password' name='none' hidden />
    
13.05.2016 / 20:59