Eitan Adler <li...@eitanadler.com> writes: > On 25 July 2016 at 13:32, Nils Dagsson Moskopp < > n...@dieweltistgarnichtso.net> wrote: > >> Eitan Adler <li...@eitanadler.com> writes: >> >> > 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). >> >> Why do you see a problem with that? >> > > Since this is semantically confusing and quite magical behavior. I don't > expect a different keyboard if i provide pattern="hello+ (world|to you)"
I suggest to file a bug against your user agent if it does that. Btw, I would appreciate to have some method to input only allowed tokens, even for such a case. >> >> > 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. >> >> This is wrong; text containing only digits is not a number. >> > > I know its wrong. Hence this post. > >> 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. >> >> Please continue to use text input elements and the pattern attribute. >> > > See also the remainder of my email. I do not understand. What do you mean? -- Nils Dagsson Moskopp // erlehmann <http://dieweltistgarnichtso.net>