How to use autocomplete=”new-password” In HTML

Using this the browser will give random password suggestions while filling the password field in any form. So the actual password will not be saved in the browser. The browser hides the actual password and showing rand suggestions all the time.

<input type = "password" autocomplete="new-password">

Example: In this example we will use the autocomplete=”new-password” method to prevent browser to remember password.

html




<html>
  
<body>
    <div>
        <h2 style="color: #006400;">
            Preventing Password remember
        </h2>
        <form name="Frm">
            User Name :
          <input id="username" type="text" 
                 name="userName" />
            <br /><br />
            Password:<input id="password" type="password" 
                            name="passWord" autocomplete="new-password" />
            <br /><br />
            <!--used autocomplete="new-password" -->
            <input id="uname" type="submit" />
        </form>
    </div>
</body>
  
</html>


Output: 



How to prevent browser to remember password in HTML ?

Browsers remember information that is submitted through <input> fields on websites for the first time when we use that particular website in that browser. So another time when we again submit data on that website through that browser then there is a suggestion list of submitted values in that field. Many times this may create security issues for many cases. Some of the methods are as:

Table of Content

  • Using autocomplete attribute
  • By Deleting cookies
  • Using autocomplete=”new-password”

Similar Reads

Using autocomplete attribute

To prevent the browser from remembering passwords in HTML, set the autocomplete attribute to “off” in the form tag. This attribute prevents the browser from suggesting or saving previously entered passwords for the form....

By Deleting cookies

...

Using autocomplete=”new-password”

...