Ravi Tewatia
Ravi Tewatia

Reputation: 1

Don't autofill username and password in chrome browser in React

I'm working on a React application and I'm encountering an issue with Chrome's autofill feature. When I have input fields for usernames and passwords, Chrome automatically fills in the information, which is causing usability problems for my users. I want to disable this autofill behaviour for security and user experience reasons.

I've tried adding the autocomplete="off" attribute to the input fields, but it doesn't seem to work as expected. Chrome continues to autofill the fieldsenter image description here below code

what need to do to remove autofill autoComplete=off

Upvotes: 0

Views: 1038

Answers (1)

Adetayo Akinsanya
Adetayo Akinsanya

Reputation: 1

I think should be able to turn it off using the autocomplete prop on the input you can try something like this, by making the role equals presentation, together with autocomplete prop you already have, also set autocomplete to new-password for a password input field.

<form autocomplete="off">
  <input role="presentation" type="text" name="username" 
   autocomplete="off" />
  <!--OR-->
  <input role="presentation" type="text" name="email" autocomplete="off" 
   />

  <input role="presentation" type="password" name="password 
     autocomplete="new-password" />
</form>

Upvotes: 0

Related Questions