
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM Input Text Autocomplete Property
The HTML DOM Input Text autocomplete property is associated with the autocomplete attribute of the <input> element with type=”text”. The autocomplete attribute takes “on” or “off” value. The on value specifies that the web browser must automatically complete user text based on previous input while false states otherwise.
Syntax
Following is the syntax for −
Setting the autocomplete Property −
textObject.autocomplete = "on|off"
Here, on means the browser will complete the user input automatically based on previous input while false states that it will not complete any of the user input based on previous inputs. It has the value set to on by default.
Example
Let us look at an example for the Input text autocomplete property −
<!DOCTYPE html> <html> <body> <h1>Input text autocomplete property</h1> <form action="/https/www.tutorialspoint.com/Sample_page.php"> USERNAME: <input type="text" id="TEXT1" name="USR" autocomplete="on"><br><br> <input type="submit"> </form> <p>Off the autocomplete in the above text field by clicking on the below button</p> <button onclick="changeAuto()">Autocomplete Off</button> <p id="Sample"></p> <script> function changeAuto() { document.getElementById("TEXT1").autocomplete = "off"; document.getElementById("Sample").innerHTML = "Your text will not autocomplete now"; } </script> </body> </html>
Output
This will produce the following output −
On typing some text in the above field and submitting it a few times to see your text autocomplete based on your previous input −
On clicking the “Autocomplete Off” button −