html icon indicating copy to clipboard operation
html copied to clipboard

Is it possible to annotate an autocomplete attribute to accept either `email` or `tel`?

Open samuelgoto opened this issue 5 months ago • 5 comments

What is the issue with the HTML Standard?

In account creation forms, there are often input boxes that accept either an email address or a telephone number from an user.

Welcome to my website!
<input id="id" alt="Enter your email or phone number!">

Is it possible to use the autocomplete attribute to accept either one or the other? Say, would the following be valid HTML5 syntax? <input autocomplete="email tel">?

Based on my reading of this, I believe this isn't a supported mode of operation.

If possible, any chance you can clarify how to accomplish this?

If not, any chance this might make sense? And if so, how (e.g. should we use empty space as a separator? or introduce a micro syntax like a name | email pipe between values?)?

samuelgoto avatar Jun 12 '25 23:06 samuelgoto

This seems like a duplicate of #4445.

The general idea does make sense to me.

annevk avatar Jun 13 '25 14:06 annevk

This seems like a duplicate of https://github.com/whatwg/html/issues/4445.

I think they are very related, but not quite the same: usernames-or-email are very different from email-or-tel because usernames (as was pointed out in that thread) can be an email or a tel, but not the other way around: usernames are arbitrary unique strings, but they aren't a re-engagement communication channel.

That is, usernames are a superset of email-or-tel, but it is most common that you actually want the constrained version: only email or tel but no "arbitrary unique strings" (because, as I said, you need a communication channel).

FWIW, I really like the -or separator, rather than or |, so that was nice to see discussed there.

But, just wanted to point out that, while related, I do think that usernames are meaningfully different than email and tel.

samuelgoto avatar Jun 13 '25 15:06 samuelgoto

I guess it depends on whether you look at that issue as solely providing "username or email" or a more generic "or" operator for autocomplete. Perhaps these are all isolated enough that we don't need something generic.

annevk avatar Jun 16 '25 06:06 annevk

I'd be curious about the use cases here. How common does this occur in practice? How does a website go about validating what can be wildly different inputs (I assume the answer is "use script")?

It might be useful to produce some examples of this kind of pattern in the wild, to help build out the motivation for such an addition to the platform.

keithamus avatar Jun 16 '25 14:06 keithamus

I'd be curious about the use cases here. How common does this occur in practice? How does a website go about validating what can be wildly different inputs (I assume the answer is "use script")? It might be useful to produce some examples of this kind of pattern in the wild, to help build out the motivation for such an addition to the platform.

Here are a examples I foud in the wild of account creation flow that uses emails and phone numbers interchangeably in a single field:

Image Image Image

samuelgoto avatar Jun 16 '25 17:06 samuelgoto