Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 99250

Rounding with NumericTextBox

$
0
0

Hi Alexander,

Thanks for your reply, but this doesn't resolve my problem as I'm already specifying the precision.

in your example you set the decimals to 16, in my case I need it to be three. Here is how you can replicate my issue withing your example:

change the decimals to be 3.

Input the following value : 1.9999 (notice that you can put a number with decimals exceeding 3)

Tab out, the value will change to 2.000; this is my issue. I need it to be 1.999 either by only allowing 3 decimals in the input or by disabling the rounding.

I tried use the following function for the onchange event, but it didn't work as the value was already rounded to 2.000 when the event is fired.

function displayMyNumberProperly(e) {
    var mult = Math.pow(10, this.options.decimals);
    if (this.value() > 0) {
        this.value(Math.floor(this.value() * mult) / mult)
    } else {
        this.value(Math.ceil(this.value() * mult) / mult)
    }
};

 


Viewing all articles
Browse latest Browse all 99250

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>