The site has two html forms: one for registration and the other for logging in registered users. Such a problem: if the browser remembers the login and password in the login form, then it also substitutes this data in the registration form, and it substitutes the wrong one in the email field. How to prevent the browser to substitute data in the form for registration?

<form id="regform" action="" method="post" autocomplete="off"> <p> <input type='text' name='login' id="username" value="" placeholder ="логин" required/> </p> <p> <input type='email' name='email' value="" placeholder ="почта" required/> </p> <p> <input type='password' name='password' value placeholder ="пароль" required/> </p> <p> <center><input type='submit' name='reg' value='Готово'/></center> </p> </form> 

 <form id='login' action='login.php' method='post' autocomplete="off"> <table> <tr> <td>Логин:</td> <td> <input type='text' name='login'/> </td> </tr> <tr> <td>Пароль:</td> <td> <input type='password' name='password'/> </td> </tr> <tr> <td colspan='2'> <br><center><input type='submit' value = 'Войти' /></center> </td> </tr> <tr> <td colspan='2'> <br/><a href="reset.php" class="interfacelink">восстановить пароль</a> </td> </tr> </table> </form> 

registration form

  • The problem is relevant for Chrome, it works fine in Firefox. - Igor

1 answer 1

Turn off auto-completion of the registration and authorization form fields in this way (example of one field):

 <input name="pass" type="password" autocomplete="off"> 
  • Autocomplete disabled, cookies deleted. Problem still exists. The browser offers to remember the username and password for the site, and then again incorrectly substitutes the data in the registration form. Data is entered into the login form correctly. - Igor
  • @Igor, complete the html question with the input and login input code from the registration and authorization form. - Visman
  • @Igor, list for each input on the registration form autocomplete="new-data" . Modern browsers do not behave exactly as expected: developer.mozilla.org/en-US/docs/Web/Security/… - Visman
  • autocomplete = "new-password" worked. Thank! - Igor