Turn off Autocomplete for Input in React

Published on November 30, 2021 32 sec read

In this short article, we are going to learn how to disable autocomplete of an input field in React. Let’s see:

Table of Contents

  1. Disable in Specefic Input
  2. Disable in Entire Form

Disable in Specefic Input

To disable autocomplete for a specific input field, we need to set autoComplete attribute to off. Example:

import React from "react";

export default function App() {
  return (
    <div theClassName="App">
      <input type="text" autoComplete="off"/>
    </div>
  );
}

Disable in Entire Form

To disable autocomplete for an entire form, we need to set autoComplete attribute with off value in the form like this:

import React from "react";

export default function App() {
  return (
    <div theClassName="App">
      <form autoComplete="off">
         <input type="text"/>
      </form>
    </div>
  );
}
That’s it. Thanks for reading. 🙂

Monthly Newsletter

One email a month, packed with the latest tutorials, delivered straight to your inbox.
We'll never send any spam or promotional emails.
Author

Hey, I'm Md Obydullah. I build open-source projects and write article on Laravel, Linux server, modern JavaScript and more on web development.

Follow