W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2016

[whatwg] proposal for new <input> inputmode: digits

From: Eitan Adler <lists@eitanadler.com>
Date: Mon, 25 Jul 2016 09:01:01 -0700
Message-ID: <CAF6rxg=7EZpRjAbd3AECZ-=fsBRm4PaL3=qCPVGi85_3d0=_ng@mail.gmail.com>
To: "whatwg@whatwg.org" <whatwg@whatwg.org>
At the moment if you'd like the user to enter *only* digits (no separators,
+, -, etc.) you must resort to a hack

<input type="text" pattern="\d*" />

This results in a correct "digits only" keyboard on some mobile keyboards
(and nothing on desktops).

There are several use cases for digits only, but the main ones that come to
mind are TOTP codes, CVV codes for credit cards, etc.

<input type="number" min="100000" max="999999" step="1" />

might work, but is non-obvious and still results in buttons for "+", "-",
and "." in some mobile browsers.

In addition, it may be useful to allow minlengt and maxlength for numeric
inputs. This can result in better error messages where the value to be
entered needs to be copied from somewhere, and so the minimum and maximum
are really proxies for length.

Eitan Adler
Received on Monday, 25 July 2016 16:02:01 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:38 UTC