Disable HTML form input autocomplete and autofill in React
✓ Published0🌍 Public
MMonaiThang
Last edited Aug 13, 2020
Created on May 29, 2020
This example shows how to prevent Chrome autofill and autocomplete on React input fields by manipulating the `autoComplete` attribute. It demonstrates two approaches: setting `autoComplete="disabled"` directly on the `input` element, and using an `onFocus` handler that calls `setAttribute` to force the attribute to "disabled" when React would otherwise render "off". The code uses React's synthetic event system and JSX syntax within a functional component, referencing Chromium’s form style documentation for alternatives like `new-password`.
AI-generated description