How To Disable HTML Input Autocomplete

In this tutorial we will see How To Disable HTML Input Autocomplete. HTML autocomplete attribute is used for this which can turn on and off autocomplete function of html input elements.

HTML Code

HTML Code is given below. In this code we have used autocomplete attribute in html input field. The value of autocomplete attribute is set to off. This will stop the browsers to predict the values for html input field.

<input name='name' type="text" placeholder="Name:" autocomplete="off">

Disable Autocomplete in all Input Fields

In this code we have used autocomplete attribute inside all input elements. The value of autocomplete attribute is set to off. This will stop the browsers to predict the values of all html input fields.

<!DOCTYPE html>
<html>
<head>
  <title>Disable Autocomplete in all Input Fields</title>
  <meta charset="utf-8">
</head>
<body>
  <form>
   <input name='name' type="text" placeholder="Name:" autocomplete="off">
   <input name='email' type="email" placeholder="Email:" autocomplete="off">
   <input name='submit' type="submit" value="Submit">    
  </form>
</body>
</html>

Demo

Disable Autocomplete in HTML Form

In the next example, autocomplete attribute is used inside the form tag only, instead of using it on all input fields you can also use it inside the form tag to disable the autocomplete function for all input fields of form tag.

<!DOCTYPE html>
<html>
<head>
  <title>Disable Autocomplete in HTML Form</title>
  <meta charset="utf-8">
</head>
<body>
  <form autocomplete="off">
   <input name='name' type="text" placeholder="Name:">
   <input name='email' type="email" placeholder="Email:">
   <input name='submit' type="submit" value="Submit">    
  </form>
</body>
</html>

Demo

Disable Autocomplete in all Input Fields Except One

In this example autocomplete is turned off for all input fields except for one. The autocomplete="off" is used inside the form tag to turn off autocomplete feature for all input fields. Then it is turned on for email input field by using autocomplete attribute in this field with the value on. Consider the code below.

<!DOCTYPE html>
<html>
<head>
  <title>Disable Autocomplete in all Input Fields Except One</title>
  <meta charset="utf-8">
</head>
<body>
  <form autocomplete="off">
   <input name='name' type="text" placeholder="Name:">
   <input name='email' type="email" placeholder="Email:" autocomplete="on">
   <input name='submit' type="submit" value="Submit">    
  </form>
</body>
</html>

Demo

Video Tutorial

Watch video tutorial on How To Disable HTML Input Autocomplete.