Form autocomplete Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form


The autocomplete property sets or gets the autocomplete attribute in a form.

Set the autocomplete property with the following Values

Value Description
onDefault. The browser will fill values based value entered before
off The browser does not automatically complete entries

Return Value

A String, representing the state of autocompletion

The following code shows how to Set autocomplete to off:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<form id="myForm" action="#" autocomplete="on">
  First name:<input type="text" name="fname"><br>
  E-mail: <input type="email" name="email"><br>
  <input type="submit">
</form>/*w ww  . j av  a2s .c om*/

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {
    document.getElementById("myForm").autocomplete = "off";
    document.getElementById("demo").innerHTML = "autocomplete is now 'off'.";


Related Tutorials