Cleave.js: input type="number" will cause error on numeric field with thousand separator

Created on 14 Jul 2018  Â·  7Comments  Â·  Source: nosir/cleave.js

THE JS

$('.fund-input').each(function (index, field) {
  var dc = $(this).data('decimal');
  dc = typeof dc !== 'undefined' ? dc : 5;

    new Cleave(field, {
      numeral: true,
      numeralThousandsGroupStyle: 'thousand',
      numeralDecimalScale: dc
  });
);

THE HTML
<input class="form-control fund-input empty" autocomplete="off" placeholder="0.00" name="amount" type="number" value="">

image
@nosir

Most helpful comment

[...]The library should simply support appropriate options.

<input type="number"> simply doesn't support input other than valid floating-point numbers.

All 7 comments

Hello!

Could you try to change the input type to "tel"?

As far as I know, the "tel" input type works just like the "number", but it allows you to have commas and dots in it. It also doesn't have the right-side buttons (↑ and ↓) to increase or decrease the number. Another good thing is that this input type works just as expected in mobile, as it opens the number keyboard to the user.

<input class="form-control fund-input empty" autocomplete="off" placeholder="0.00" name="amount" type="tel" value="">

It isn't a semantic option to use tel in any case other than phone numbers. The library should simply support appropriate options.

Hi, I am having the same issue, with the "tel" keyboard the user cannot insert the dot to add decimals, so is not a valid solution for me neither.

Tel does _not_ work just like number. It allows for similar formats, but on android devices (at least) the period is pushed to second page and is not readily visible by users, along with several other unnecessary characters. Requiring any extra keypresses to force a solution to fit in a box is terrible practice. Going to reiterate what others have been commenting - "number" type inputs need their own coverage.

tel != number

[...]The library should simply support appropriate options.

<input type="number"> simply doesn't support input other than valid floating-point numbers.

any news on this one?

As indicated by @pimskie

<input type="number"> simply doesn't support input other than valid floating-point numbers.

Cheers

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrozado picture mrozado  Â·  3Comments

dan-kez picture dan-kez  Â·  5Comments

Scit picture Scit  Â·  4Comments

periabyte picture periabyte  Â·  7Comments

CaptainYarb picture CaptainYarb  Â·  3Comments