The autocomplete Attribute in HTML5

Here we will learn use of autocomplete attribute.

Introduction: The autocomplete attribute is used to provide help for user during form entry by showing previous entered data in 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 attribute in our page. We write the following code

<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" />

Now we run this code. The output will look like below figure

 autocomplete attribute

We do entry for form and click on 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 new input text. The autocomplete state if off for account number, so no previous Like as below

autocomplete attribute