Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to disable autocomplete of an HTML input field ?

  • Last Updated : 06 Sep, 2021

In this article, we will learn how to disable or off autocomplete features of a particular input field in HTML form. As we know that autocomplete feature is used to allow a browser whether to automatically complete filled the input data value based on the values that the user entered before. As the latest browsers supports enabled autocomplete by default. The autocomplete feature faster the process of filling the form. In case of low internet excess or session expired, if the autocomplete is enabled then the browser automatically filled the data values that the user entered before. 

Autocomplete attribute take two values:

  • on: It specifies that autocomplete is enabled.
  • off: It specifies that the autocomplete is disabled.

If you want to disabled autocomplete feature then follow the approach which are given below: 

Approach: 

  • First we create an HTML document that contains an <input> tag.
  • Use the <input> tag with autocomplete attribute
  • Set the autocomplete attribute to value “off”.

 

Example: Below code demonstrates that a form has two input fields, one with autocomplete status is on and in the other field autocomplete feature is off.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>
        How to disable autocomplete 
        of an HTML input field?
    </title>
  
    <style>
        h1,
        h2 {
            font-family: impact;
        }
    </style>
</head>
  
<body style="text-align:center;">
  
    <h1>GeeksForGeeks</h1>
  
    <h2>
        How to disable autocomplete 
        of an HTML input field?
    </h2>
  
    <form id="myGeeks">
        Name:<input type="text" id="text_id" 
            name="geeks" autocomplete="on">
        <br>
        Address: <input type="Address" 
            name="address" autocomplete="off">
        <br><br>
  
        <input type="submit">
    </form>
</body>
  
</html>

Output: 

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!