A popular tweet of mine that’s been doing rounds again (thanks to an RT by Stefan, whom you should definitely follow) is this little tip:
💡 This works wonderfully well with HTML by the way, as you can have a single input[type="email"] take multiple entries.https://t.co/Gm94MdQRo3
— Bramus! (@bramus) December 4, 2020
By setting the
multiple attribute on an
input[type="email"] you can have it accept multiple entries. Each entry is separated by a comma and is validated individually.
Here’s a little demo video of how that works:
However, it was pointed out to me that on iOS this isn’t usable by default:
Ironically, iOS(iPhone) keyboard dosnt show comma for this İnput field. Cant even try it
— Errorist (@orhnarkn) December 4, 2020
On iOS, the “email keyboard” looks like this, with no comma to be found (not even when switching to numbers/symbols):
To work around this limitation you can manually override the input to use the regular keyboard by setting the
inputmode attribute to
That way we still have the built-in browser validation rules (triggered by
[type="email"]) and a means to type in a comma (triggered by
[inputmode="text"]). Double win!
💁♂️ Sidenote: With this
inputmode attribute you can create better number inputs.
Combining what we know, here’s a full demo for you to play with: