Open In App

How to disable autocomplete of an HTML input field ?

Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will learn how to disable or off autocomplete features of a particular input field in HTML form. As we know the autocomplete feature is used to allow a browser to automatically complete the input data value based on the values that the user entered before. The latest browsers support enabled autocomplete by default.

The autocomplete feature faster the process of filling the form. In case of low internet excess or session expiration, if the autocomplete is enabled then the browser automatically fills the data values that the user entered before. 

Syntax:

<input type="text" autocomplete="off">

Attribute Values:

Attribute Values

Description

on

It specifies that autocomplete is enabled.

off

It specifies that the autocomplete is disabled.

Example: The 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>
</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: 

fert



Last Updated : 30 Jan, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads