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 |
---|---|
on | Default. The browser will fill values based value entered before |
off | The browser does not automatically complete entries |
A String, representing the state of autocompletion
The following code shows how to Set autocomplete to off:
<!DOCTYPE html> <html> <body> <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> <script> function myFunction() { document.getElementById("myForm").autocomplete = "off"; document.getElementById("demo").innerHTML = "autocomplete is now 'off'."; } </script> </body> </html>