Restrict jQuery spinner rounding off

524 Views Asked by At

I am using a jQuery spinner. When I set it to a value, and use step=1, I expect it not to be rounded off. How can I do that?

Here's the fiddle:

http://jsfiddle.net/rfnjzre1/

<input id="spinner" name="value" step=1 value="87.67">

The value is 87.67. With step=1, I want the value to be 88.67, not 89.

How to do that?

Thanks

2

There are 2 best solutions below

6
On BEST ANSWER

Here's what you can do: JsFiddle

Basically, jquery ui is a bit tricky when it comes to decimals - There is a globalize value called numberFormat that should fix this for you much simpler, but I cannot find any documentation to the right value.

Instead, I intercepted the "spin", and set the value myself - therefore allow me to change the value to whatever I want it to be.

In order for this to work both with negative and positive numbers you have to use StepUp and StepDown.

3
On
`http://jsfiddle.net/rfnjzre1/12/`

Let me know if this works for you. Thanks