Skip to content

Disable autocomplete for all input fields in a form

Autocompleting a field is great except when it's not.

"However, some data submitted in forms are either not useful in the future (for example, a one-time pin) or contain sensitive information (for example, a unique government identifier or credit card security code). As website author, you might prefer that the browser not remember the values for such fields, even if the browser's autocomplete feature is enabled."  -MDN web docs

Turn off autocomplete for one field:

<input name="q" type="text" autocomplete="off"/>

When you have quite a few input fields, adding that attribute to every field might be painful. Therefore: turn off autocomplete for the entire form:

<form action="/form" method="post" autocomplete="off" >
[…]
</form>