Signup/Sign In

How to disable autocomplete of an input field?

The autocomplete helps the user to suggest possible text to complete the text field. When the user starts typing the suggestion appears on the screen. It is the default feature supported by the browser.

In this tutorial, we will learn to disable the autocomplete of the input field.

Disabling autocompletion

The input field is created using the <input> tag. To disable the autocomplete use autocomplete="off" attribute within the <input> tag. If you want to disable the autocomplete of input field for the entire form use the autocomplete attribute within the <form> tag.

Example: Disabling the autocomplete of the input field

Here, we have created an input field that will give no suggestion to the user.

<!DOCTYPE html>
<html lang="en">
<meta name="viewport" content="width=device-width, initial-scale=1">
    <h3> No more suggestion </h3>       
   <label for="cd">Search Here </label>
   <input type="text" id="cd" name="cd" autocomplete="off"> 


Here is the output of the above example.

Disabling autocomplete

Example: Disabling input field of the entire form

Here, we have used the autocomplete="off" to the form to disable the suggestion of the entire form.


In this tutorial, we have learned to disable autocomplete of the input field. To do so use autocomplete="off". You can use it on <input> or <form> element.

About the author: