How to remove auto-complete from form inputs
In this article, we will learn how to remove auto-complete from form inputs of HTML, in a simple way using a native attribute of the language itself.
Hey you programmer, okay? Let’s learn something new!
Auto complete is a sensational feature, it helps users who have already filled in data on another site to retrieve them and use them on other sites
But it can often cause a problem, so how can we fix it?
The answer is quite simple, we need to use an attribute called autocomplete in the form
And then set the value of this attribute to off, see the example:
<!DOCTYPE html> <html> <head> <title>Como remover o auto complete de inputs</title> </head> <body> <h1>Preencha o formulário</h1> <form autocomplete="off"> <input type="email" name="email" placeholder="Digite seu e-mail"> <input type="password" name="password" placeholder="Digite sua senha"> <input type="submit" value="Login"> </form> </body> </html>
We have a login form, and as mentioned before it has the autocomplete attribute with a value set to off
This will cause the functionality to be disabled in this form, thus solving our problem
Remembering that you should use this wisely, as taking a resource from the user can be very harmful to your system
Always think carefully about his journey, when changing a default or expected behavior that he might miss
Because it can lead to code that is difficult to read and bad to maintain, always think about the next one that will take this code
In this article we learned a way to remove auto-complete from form inputs of HTML
We simply add the autocomplete attribute with an off value to the form tag and the problem will be solved
Want to improve your HTML skills? Click here!