W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2011

[whatwg] Form input element for value-unit pairs

From: Christoph Päper <christoph.paeper@crissov.de>
Date: Tue, 15 Mar 2011 17:36:41 +0100
Message-ID: <AEA823F5-027B-43FE-94FD-94D709D0923D@crissov.de>
Jukka K. Korpela:
> Christoph P?per wrote:
> 
>>  <input type="number" id="fontsize" value="12" unit="pt">
> 
> Or do you mean that the presence of the unit="..." attribute would trigger a special implementation of numeric input, so that the user is expected to enter both a number and a unit, with the latter defaulted according to the unit attribute?

Yes. 

UIs may autoconvert the value if the unit changes or keep it. I?m not sure which solution is better.

> Although the need for number & unit input is relatively common, I think it can quite satisfactorily be handled using a number input field and e.g. a dropdown menu of units accepted by an application (or maybe a textfield). After all, processing of the form data would most probably want to split a combined number & unit data item into its components, so why put them together in the first place?

Usability.

Maybe it would work better with ?datalist?:

  <input name=fontsize type=number unit=typo>
  <datalist id=typo>
    <option value=2.835 label=pt>
    <option value=1 label=mm>
  </datalist>

or

  <input name=fontsize type=number unit=#typo>
  <datalist id=typo>
    <option value=pt label=point>
    <option value=mm label=millimetre>
  </datalist>
Received on Tuesday, 15 March 2011 09:36:41 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:31 UTC