how to turn off autocomplete for form’s input field in React JS?

I am explaining you, how to turn off autocomplete for form’s input field in React JS. here is very easy process to turn off autocomplete in input fields in form. I am giving some explanation to turn off separately input fields and other through form’s.

Table of Contents –

1. Disable with Entire Form

2. Disable with Input field

1. Disable with Entire Form

If you want to disable autocomplete for an form, you need to set autoComplete attribute set off value in the form.

Example :

import React from "react";

export default function App() {
  return (
    <div className="App">
      <form autoComplete="off" id="registration">
         <input type="text" name="username" id="username" />
      </form>
    </div>
  );
}

2. Disable with Input field

If you want to disable autocomplete to a specific input field so you need to set autoComplete attribute value set off.

Example :

import React from "react";

export default function App() {
  return (
    <div className="App">
      <form  id="registration">
         <input autoComplete="off" type="text" name="username" id="username" />
      </form>
    </div>
  );
}

Leave a Reply

Your email address will not be published. Required fields are marked *