1

We have a simple input field with the type number. When we display large numbers the value that is visible in the element is different to the one that is in the field. This only happens on firefox (testet with version 30.0).

If I have following code the value written in html is 9999999999999999 but firefox displays 10000000000000000.

<input type="number" min="0" max="9999999999999999" value="9999999999999999">

Is there any solution to show a numeric input field on mobile devices without the type number or solve this problem?

jsfiddle

Benjamin P.
  • 453
  • 5
  • 12
  • I dont know the solution or reason for your situation but see this code [snippet](http://jsfiddle.net/vce9s/), which allows entry of only numbers in text type input field, [Reference](http://stackoverflow.com/questions/3368546/what-input-field-type-forces-the-number-pad-mobile-keyboard-to-come-up-when-focu) – Mustafa sabir Jul 03 '14 at 08:11

1 Answers1

1

Just try fiddle in FF and Chrome:

alert(9999999999999999);//return 10000000000000000
alert(999999999999999);//return 999999999999999

I think it's a IEEE 754 spec "feature" (like 0.1 + 0.2). Try IEEE 754 converter and you will see why result was changed.

Alex
  • 11,115
  • 12
  • 51
  • 64
  • Could this also be the reason for other number changes? Like when i change the value to 4242424242424242 the last number changes to a 0. – Benjamin P. Jul 03 '14 at 08:34
  • If you change `number` input value by javascript and it value became 0 - it's a bug. May be [this](https://bugzilla.mozilla.org/show_bug.cgi?id=1005603). Also `number` input was implemented in FF28 with a lot of [bugs](https://bugzilla.mozilla.org/buglist.cgi?quicksearch=number+input). I don't use it in FF now. – Alex Jul 03 '14 at 08:48