I am designing a web app. In some places, the user will have to enter a single digit. I would like the input for the digit to meet the following criteria:
- I don't want the arrow buttons (a.k.a. "spin buttons") to show up, since I think they are unnecessary clutter.
- I want the number keyboard to show up on any device without a physical keyboard, or at least on recent iOS and Android devices. The normal text keyboard is full of unnecessary clutter.
- I do not want the validation behavior for number inputs built into recent versions of Firefox (red border, tooltip). I am planning to use my own validation, or maybe do without it.
- I would prefer to avoid any browser-specific hacks.
This is what I tried and why my attempts were disappointing:
- First, I tried using
<input type="number">
. The arrow buttons showed up in Firefox on my Mac. I managed to disable Firefox's validation by setting aninput
event handler on the input with the linethis.setCustomValidity(" ")
. - Next, I tried doing some research and found this question. It mentioned a bunch of stuff that looked like it would only work on Webkit. I didn't actually try it.
- Next, I tried using a text input (
<input type="text">
) with thepattern
attribute set to[0-9*]
. According to this answer, that should make the number keyboard come up. It did that in iOS, but not in Android.
I know about the inputmode
attribute that is meant for this purpose, but it doesn't seem to be supported at all.
Does anyone know of a way to implement a sane cross-browser number input? Is what I am asking for unreasonable?