A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

[Proposal] input[type=currency]

buddhalow
2021-06-26

Many web apps takes input from users that consists of monetary value in a specific currency. Today, these web applications relies on third party js libraries that can make a regular input behave like a monetary field (thousand and fraction separators, currency symbols etc). To make opportunity for a more consistent user experience and easier development work for web developers, I want to propose an new input type, the currency input type. Example how it should render below:

The formatting of the value of the currency used is determined by a “currency” attribute and a ‘locale’ attribbute, and in the field should be formatted according to Number.toLocaleString(’<value of locale attribute’, {style: ‘currency’, currency: '}) but this only apply for formatting the visible value. The value send in the corresponding post field and the .value attribute of the field should be a pure JavaScript Number field, formatted as a float, as most web apps want to get a pure number without any visible formatting.

tomayac
2021-06-29

I have a proposal baking in my head for a while that looks related, but extends your idea. You posting this has triggered me to write down mine.