Jump to: navigation, search

HTML form autocomplete

From w3cyberlearnings

Contents

HTML - autocomplete attribute

The autocomplete attribute can be used with the form level or with the form elements level. Assign the autocomplete in the form level it affects all the form elements. However the autocomplete can be used in each individual form elements. When a form or html form elements have the autocomplete turn on, the web browser will automatically complete the form input field values based on the previously entered value when user tries to fill in.

HTML - Syntax autocomplete attribute set on in the form level

  • Set all the form elements to autocomplete on.
 <form action="" autocomplete="on">

 </form>

HTML - Syntax autocomplete attribute set off in the form level

  • Set all the form elements to autocomplete off.
 <form action="" autocomplete="off">

 </form>

HTML - Syntax autocomplete attribute on or off in the form elements level

 <form action="">
       <input type="text" name="my_name" size="20" autocomplete="off"/>
       <input type="text" name="my_school" size="20" autocomplete="on"/>
 </form>

Example 1: Set autocomplete off in the form level

<html>
<head>
<title>Autocomplete form level</title>
</head>
<body>
<form action="" autocomplete="off">
Name: <input type="text" name="my_name" size="20"/><br/>
School: <input type="text" name="my_school" size="20"/>
<input type="submit" value="Save" />
</form>
</body>
</html>

Example 2: Set autocomplete in the form elements level

<html>
<head>
<title>Autocomplete</title>
</head>
<body>
<form>
Name: <input type="text" name="my_name" size="20" autocomplete="off"/><br/>
School: <input type="text" name="my_school" size="20" autocomplete="on"/>
<input type="submit" value="Save" />
</form>
</body>
</html>

Output

Html form autocomplete 2.png

Related Link


Navigation
Web
SQL
MISC
References