The autocomplete Attribute in HTML5
The autocomplete attribute is used to provide
help for the user during form entry by showing previously entered data in the drop-down
list for re-entering data. The autocomplete attribute has two states, on and off. By default, its state is on for form. Now we use autocomplete attributes on our page. We write the following code:
- <!DOCTYPE HTML>
- <html>
- <body>
- <form method="post" autocomplete="on">
- First Name
- <input type="text" name="fname" />
- <br/>
- Last Name
- <input type="text" name="lname" />
- <br/>
- Account No.
- <input type="text" name="ac" autocomplete="off" />
- <br/>
- <input type="submit" />
- </form>
- </body>
- </html>
Now we run this code. The output will look like the below figure:
We do the entry for form and click on the submit
button. We will note here that, when we do re-entry for First Name and Last Name then a drop-down list is displayed of previous input matched with the new input text. The autocomplete state if off for account number, so no previous
Like as below: