Open In App
Related Articles

What is the significance of adding autocomplete attribute in HTML Form ?

Improve Article
Improve
Save Article
Save
Like Article
Like

The HTML <form> autocomplete attribute is used to specify that the form has autocompleted on or off value.  When the autocomplete attribute is set to “on“, the browser will automatically complete the values based on which the user entered before. 

Syntax:  

<form autocomplete="on|off">

Attribute values:

  • on: It has a default value. When the autocomplete attribute is set to “on” the browser will automatically complete the values based on which the user entered before.
  • off: The user should have entered the values of each field for every use. The browser should not autocomplete entries.

Example 1: This example illustrates the use of the <form> autocomplete attribute set to “on”.

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML Form autocomplete Attribute
    </title>
</head>
 
<body style="text-align:center">
 
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
 
    <h2>HTML form autocomplete Attribute</h2>
 
    <form action="#" method="post"
          id="users" autocomplete="on">
 
      <label for="username">
        Username:
      </label>
 
      <input type="text" name="username"
             id="Username">
        <br>
      <label for="password">
        Password:
      </label>
 
      <input type="password" name="password"
             id="password">
        <br>       
    </form>
</body>
</html>

Output:         

Example 2: This example illustrates the use of the <input> autocomplete attribute set to “off”.

HTML




<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <h1 style="color:green;">Welcome to GeeksforGeeks</h1>
    <form id="formID">
        <input type="text" autocomplete="off"
              id="text_id" name="name">
        <input type="submit">
    </form>
</body>
</html>

Output:        


Last Updated : 28 Feb, 2022
Like Article
Save Article
Similar Reads
Related Tutorials