Re: [suggestion] Another field type for HTML form inputs

Hi Felipe,

Other than the currency sign, input type=number allows for most of the
requirements that you're stating.

As for the currency symbol: You wouldn't want to change it based on
locale, because a currency has a specific value, which is different
when using a different currency. It's impossible to include currency
conversion algorithms into the browser - they would need updating too
often.

As for the styling issues of numbers - that's a CSS issue. Things like:
    thousand-separator: coma;
    decimal-separator: point;
    negative: visible; /* allows the negative symbol */
would be attributes that needed to be added to CSS - we don't add
attributes for styling into HTML.

These ideas have been kicked around in the CSS WG before, e.g. see
http://wiki.csswg.org/ideas/content-formatting . I don't know where
the discussion of this is at right now.


On Thu, May 16, 2013 at 12:10 AM, Felipe Nascimento de Moura
<felipenmoura@gmail.com> wrote:
> Hi Silvia.
>
> Well, currency is not necessarily a float value...in Brazil, currency uses
> "comma" as decimal separator and point as the thousand separator.
> Our Operational System(therefore, our browsers) know that, but float numbers
> are still the same(point for decimal with no separator for thousand).
>
> I think the advantages would be:
> * we could have the css possibilities, like :negative and :positive styles,
> or offer the option for the browser to show/hide the currency symbol as the
> user focus it or not.
> * When building a webapp, I had to apply these features via javascript
> loading extra libraries or building my own!
> * Number fields do not accept characters like coma, so, to apply a mask to
> it(in brazilian format) I had to use an input of type text :(

That's a browser implementation limitation. The spec already says:

"A user agent might support numeric input in the user's local format,
converting it to the format required for submission as described
above. This might include handling grouping separators (as in
"872,000,000,000") and various decimal separators (such as "3,99" vs
"3.99") or using local digits (such as those in Arabic, Devanagari,
Persian, and Thai)."

> * I believe it would be semantically useful and could help increasing
> usability and customization, besides avoiding some other libraries to be
> loaded unnecessarily!

Agreed.

> * Screen readers could read such fields differently...let's say, instead of
> reading "two thousand dot eleven" (a float value), it could read "two
> thousand dollars and eleven cents" or something like this.

Interesting. This is a semantic interpretation of the number. I would
encourage the use of microdata or RDFa to include the information that
this is a number of type currency. Accessibility tools could make use
of such semantic markup.


> What do you think? Maybe, just some changes could be added to the number
> input to fit these features, so there wouldn't be needed another input type?

Maybe... what are you thinking of?

Cheers,
Silvia.


>
> Cheers.
>
>
>
> On Wed, May 15, 2013 at 6:46 AM, Silvia Pfeiffer <silviapfeiffer1@gmail.com>
> wrote:
>>
>> Hi Felipe,
>>
>> The example under <input type=number> uses a currency example:
>>
>> http://www.w3.org/html/wg/drafts/html/master/single-page.html#number-state-(type=number)
>>
>> Is that not sufficient?
>>
>> Cheers,
>> Silvia.
>>
>> On Wed, May 15, 2013 at 12:56 AM, Felipe Nascimento de Moura
>> <felipenmoura@gmail.com> wrote:
>> > Hi.
>> >
>> > This is something I see a lot of people doing by themselves across the
>> > internet, or using libraries to do so. To format currency/money inputs.
>> >
>> > Therefore, I believe it would be useful if HTML could provide an input
>> > with
>> > type currency.
>> >
>> > Once the Operational System knows the user's preferences related to
>> > currency, money symbols and format, the browser should be able to render
>> > it
>> > with a better solution.
>> > Mobile devices could change their keyboards to only numbers, comas and
>> > points..maybe the symbol($) as well.
>> > These inputs, could have a mask applied, according to the currency
>> > (let's
>> > say, in Brazil, the currency format is 1.234,56 while in most countries
>> > it
>> > is 1,234.56).
>> >
>> > CSS could be able to change its "mask" as it changes list-styles, for
>> > example.
>> >
>> > input[type=currency]{
>> >     thousand-separator: coma;
>> >     decimal-separator: point;
>> >     symbol-visibility: focus; /* shows the symbol only when the input is
>> > in
>> > focus */
>> >     symbol: none;
>> >     negative: visible; /* allows the negative symbol */
>> > }
>> >
>> > I wounder symbol might be a keyword like "real", for brazilian currency
>> > (R$), dollar, us-dollar, aus-dollar, euro, etc...or it could be the
>> > string
>> > with the symbol, itself!
>> >
>> > Plus, there could be a few states for the element, such as:
>> > input[type=currency]:negative{
>> >     color: red;
>> > }
>> > input[type=currency]:positive{
>> >     color: green;
>> > }
>> >
>> > Also, those configurations could be defined in the HTML element
>> > itself...something like:
>> > <input type="currency" thousand="." decimal="," />
>> >
>> > Masks with JavaScript are expensive, there are thousands of them, each
>> > working in different ways.
>> > When building web-apps, it would make a lot of difference!
>> >
>> > So, I want to hear from you what is your opinion about it.
>> >
>> > Thanks for your time.
>> >
>> > --
>> > Felipe N. Moura
>> > Senior Web Developer
>> >
>> > Website:  http://felipenmoura.org
>> > Twitter:    @felipenmoura
>> > LinkedIn: http://goo.gl/qGmq
>> >
>> > Meet some of my projects:
>> > BrazilJS Conference  |  BrazilJS Foundation  |  Power Polygon  |
>> > TheWebMind
>> > |  PHPDevBar
>> > ---------------------------------
>> > LinuxUser #508332
>> > Changing  the  world  is the least I expect from  myself!
>
>
>
>
> --
> Felipe N. Moura
> Senior Web Developer
>
> Website:  http://felipenmoura.org
> Twitter:    @felipenmoura
> LinkedIn: http://goo.gl/qGmq
>
> Meet some of my projects:
> BrazilJS Conference  |  BrazilJS Foundation  |  Power Polygon  |  TheWebMind
> |  PHPDevBar
> ---------------------------------
> LinuxUser #508332
> Changing  the  world  is the least I expect from  myself!

Received on Wednesday, 15 May 2013 22:51:53 UTC