[whatwg] <input type=number> for year input

Smylers Smylers at stripey.com
Wed Feb 19 08:06:30 PST 2014

Jukka K. Korpela writes:

> 2014-02-19 11:10, Smylers wrote:
> > Jukka K. Korpela writes:
> > 
> > > The point is that year numbers aren't really "numbers" in a normal
> > > sense, any more than car plate numbers, credit card numbers,
> > > product numbers, or social security numbers are. Surely they can
> > > be regarded as numbers, but so can car plate numbers and the
> > > others.
> > 
> > Except that years do actually form a sequence, and it's possible to
> > perform maths on them; for instances, subtracting one year from
> > another yields a duration
> Mathematically, you are right, but input types aren't based on general
> properties of quantities but on practical classification of input
> data.

That's a reasonable way of doing it.

> All the examples I gave, including year numbers, are normally input by
> typing the digits

Many other numbers — actual, no-doubt-about-it, definitely 100% genuine
numbers — are also typically typed in.

> - in contrast with, say, using a color picker, a data picker, or a
> slider.

There are situations where up/down arrows makes sense on years. For
instance, a chart of various baby names could have a box for the year
currently being displayed, and it's handy to be able to nudge that along
by a year at a time to see it change, without having to manually retype
the year. Or when displaying one year's tax return, with the ability to
display other years' returns — with adjacent years being likely options.

Obviously not every year actually gets treated as a number, but there
are many situations where they are, and where a number input control
makes sense for them.

Contrast this with credit card numbers or telephone numbers, which never
actually get treated as numbers (unless you want a form with the ability
to easily cycle through the final digit of a credit card number until it
passes the mod 10 check!).

> And year numbers differ, as mentioned, from normal numbers as regards
> to conventional formats (e.g., 2014 vs. 2,014 or 2'014 or 2 014
> or...).

Many people, at least in the UK, don't bother with a thousands separator
in 4-digit numbers anyway, but probably would put them in a 5-digit

The style guides Mike quoted (which in general did use commas in 4-digit
numbers) also had other categories apart from years which don't use
commas, including page numbers. Page numbers are undoubtedly numbers,
and it definitely makes sense to provide up/down arrows for them.

So if we wish to be able to follow those style guides, we still need to
be able to provide comma-less <input type=number> controls for page
numbers, regardless of whether you consider a year to be a number.

If we don't care about following those style guides, we could simply go
with Hixie's suggestion of never putting thousands separators in 4-digit

In neither case does decreeing that years aren't numbers actually help.



More information about the whatwg mailing list