Javascript examples for DOM HTML Element:Input Text
The autocomplete property sets or gets the autocomplete attribute in a text field.
Set the autocomplete property with the following Values
Value | Description |
---|---|
on | Default. The browser will complete values based on values 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 in a text field to off:
<!DOCTYPE html> <html> <body> <form action="#"> Name: <input type="text" id="myText" name="fname" autocomplete="on"> <input type="submit"> </form>/* w w w . ja va 2 s. c o m*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myText").autocomplete = false; document.getElementById("demo").innerHTML = 'changed'; } </script> </body> </html>