I am using Input field from material-ui along with react, trying to set autofill off for all the fields and have tried multiple solutions available but none of them seems working properly. Tried Solutions –
- By setting autoComplete="off"
- Passed autocomplete:’off’ in the InputProps
- By setting random name for the field – this is working but doesn’t allow to enter anything into input field
- By setting unique ID/ClassName/Name attribute
- via JS script
But none of them seems working fine.
Can anyone help me with the working solution?
2
Answers
Pass
autoComplete="off"
to theInputProps
, not directly to Autocompleteyou can try below approaches for this issue.
Set the autoComplete attribute to off. This is the simplest way to disable autofill, and it should work in most browsers.
Pass the autocomplete prop to the InputProps object. This is another way to disable autofill, and it is more flexible than setting the autoComplete attribute directly.
Also you can try below JS code to use a JS script to disable autofill. This is the most secure way to disable autofill, but it is also the most complex.