If autocomplete is on in the browser, the input value is filled automatically based on the previously entered values. The autocomplete feature mostly works for the username, email, and password inputs which are saved in the browser. The browser has filled the input automatically based on the saved values.
It is possible to turn off autocomplete for form or specific input fields. The autocomplete attribute helps to specify whether form inputs should have autocompletion on or off.
You can use autocomplete
attribute in HTML <form> tag to turn off autocomplete for all input fields under a form.
<form method="post" action="" autocomplete="off">
...
</form>
The autocomplete
attribute can be used in the HTML input element to disable autocomplete for a specific input field.
<input type="text" name="username" id="username" autocomplete="off" />
Generally, the autocomplete=”off” is disabled autocomplete in input fields. But, this attribute may issue with the password input field in the Google Chrome browser. You can use the following value in the autocomplete attribute to turn off autocomplete for the password input field. It will fix the input autocomplete issue in the Chrome browser.
<input type="password" name="password_input" id="password_input" autocomplete="new-password" />