HTML DOM Input Text autocomplete Property

HTMLWeb DevelopmentFront End Technology

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.


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.


Let us look at an example for the Input text autocomplete property −

<!DOCTYPE html>
<h1>Input text autocomplete property</h1>
<form action="/Sample_page.php">
USERNAME: <input type="text" id="TEXT1" name="USR" autocomplete="on"><br><br>
<input type="submit">
<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>
   function changeAuto() {
      document.getElementById("TEXT1").autocomplete = "off";
      document.getElementById("Sample").innerHTML = "Your text will not autocomplete now";


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 −

Published on 19-Aug-2019 15:07:35