Web Forms: Now You See Them, Now You Donât! by Jason Grigsby
This was originally posted on my own site.
Jason is on stage in a tuxedo. He wants to talk about how we can make web forms magical. Oh, I see. That explains the get-up.
Weâre always being told to make web forms shorter. Luke Wroblewski has highlighted the work of companies that have reduced form fields and increased conversion.
But what if we could get rid of forms altogether? Wouldnât that be magical!
Jason will reveal the secrets to this magic. But first â a volunteer from the audience, please! Please welcome Joe to the stage.
Joe will now log in on a phone. He types in the username. Then the password. The password is hodge-podge of special characters, numbers and upper and lowercase letters. Joe starts typing. Jason takes the phone and logs in without typing anything!
The secret: Jason was holding an NFC security key in his hand. That works with a new web standard called WebAuthn.
Passwords are terrible. People share them across sites, but who can blame them? Itâs hard to remember lots of passwords. The only people who love usernames and passwords are hackers. So sites are developing other methods to try to keep people secure. Two factor authentication helps, although it doesnât help us with phishing attacks. The hacker gets the password from the phished user â¦and then gets the one-time code from the phished user too.
But a physical device like a security key solves this problem. So why arenât we all using security keys (apart from the fear of losing the key)? Well, until WebAuthn, there wasnât a way for websites to use the keys.
A web server generates a challenge â a long string â that gets sent to a website and passed along to the user. The userâs device generates a credential ID and public and private keys for that domain. The web site stores the public key and credential ID. From then on, the credential ID is used by the website in challenges to users logging in.
There were three common ways that we historically proved who we claimed to be.
- Something you know (e.g. a password).
- Something you have (e.g. a security key).
- Something you are (e.g. biometric information).
These are factors of identification. So two-factor identification is the combination of any of those two. If you use a security key combined with a fingerprint scanner, thereâs no need for passwords.
The browser support for the web authentication API (WebAuthn) is a bit patchy right now but you can start playing around with it.
There are a few other options for making logging in faster. Thereâs the Credential Management API. It allows someone to access passwords stored in their browserâs password manager. But even though itâs newer, thereâs actually better browser support for WebAuthn than Credential Management.
Then thereâs federated login, or social login. Jason has concerns about handing over log-in to a company like Facebook, Twitter, or Google, but then again, it means fewer passwords. As a site owner, thereâs actually a lot of value in not storing log-in information â you wonât be accountable for data breaches. The problem is that youâve got to decide which providers youâre going to support.
Also keep third-party password managers in mind. These tools â like 1Password â are great. In iOS theyâre now nicely integrated at the operating system level, meaning Safari can use them. Finally itâs possible to log in to websites easily on a phone â¦until you encounter a website that prevents you logging in this way. Some websites get far too clever about detecting autofilled passwords.
Time for another volunteer from the audience. This is Tyler. Tyler will help Jason with a simple checkout form. Shipping information, credit card information, and so on. Jason will fill out this form blindfolded. Tyler will first verify that the dark goggles that Jason will be wearing donât allow him to see the phone screen. Jason will put the goggles on and Tyler will hand him the phone with the checkout screen open.
Jason dons the goggles. Tyler hands him the phone. Jason does something. The form is filled in and submitted!
What was the secret? The goggles prevented Jason from seeing the phone â¦but they didnât prevent the screen from seeing Jason. The goggles block everything but infrared. The iPhone uses infrared for Face ID. So the iPhone, it just looked like Jason was wearing funky sunglasses. Face ID then triggered the Payment Request API.
The Payment Request API allows us to use various payment methods that are built in to the operating system, but without having to make separate implementations for each payment method. The site calls the Payment Request API if itâs supported (use feature detection and progressive enhancement), then trigger the payment UI in the browser. The browser â not the website! â then makes a call to the payment processing provider e.g. Stripe.
E-commerce sites using the Payment Request API have seen a big drop in abandonment and a big increase in completed payments. The browser support is pretty good, especially on mobile. And remember, you can use it as a progressive enhancement. Itâs kind of weird that we donât encounter it more often â itâs been around for a few years now.
Jason read the fine print for Apple Pay, Google Pay, Microsoft Pay, and Samsung Pay. It doesnât like thereâs anything onerous in there that would stop you using them.
On some phones, you can now scan credit cards using the camera. This is built in to the operating system so as a site owner, youâve just got to make sure not to break it. Itâs really an extension of autofill. You should know what values the autocomplete
attribute can take. There are 48 different values; itâs not just for checkouts. When users use autofill, they fill out forms 30% faster. So make sure you donât put obstacles in the way of autofill in your forms.
Jason proceeds to relate a long and involved story about buying burritos online from Chipotle. The upshot is: use the autocomplete
, type
, maxlength
, and pattern
attributes correctly on input
elements. Test autofill with your forms. Make it part of your QA process.
So, to summarise, hereâs how you make your forms disappear:
- Start by reducing the number of form fields.
- Use the correct HTML to support autofill. Support password managers and password-pasting. At least donât break that behaviour.
- Provide alternate ways of logging in. Federated login or the Credentials API.
- Test autofill and other form features.
- Look for opportunities to replace forms entirely with biometrics.
Any sufficiently advanced technology is indistinguishable from magic.
â Arthur C. Clarkeâs Third Law
Donât our users deserve magical experiences?
This was originally posted on my own site.