How to autocomplete two-factor authentication codes with a single HTML attribute
Today’s tip comes courtesy of
Tomek Sułkowski on Twitter.
If you manage an app that supports two-factor authentication, either through an app or SMS, you can make it easy for users to autocomplete their unique code. The trick is a single HTML attribute:
< label for = "two-factor-auth" >Authentication Code </ label >
< input id = "two-factor-auth" autocomplete = "one-time-code" >
Tomek setup a demo here. ( I made ). a fork on CodePen in case his goes down or you want to fork and test yourself
To use it, text yourself a short “auth code” (maybe 4 or 6 digits). You can also
read more about the .
[autocomplete] attribute on MDN
Like this? I send out a short email each weekday with code snippets, tools, techniques, and interesting stuff from around the web. Join 10,500+ daily subscribers.