Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove comma for Javascript function toLocaleString

I am currently trying to deal with numbers for both English (en) and German (de) languages. I have a global function which does this and works fine until the number reaches 1000 or more.

    function getLocaleString(floatValue) {
    var CurrentCulture = $('#CurrentCulture').val();
    if (CurrentCulture != "" && CurrentCulture != null) {
    return floatValue.toLocaleString(CurrentCulture, { minimumFractionDigits: 2, 
    maximumFractionDigits: 2 });
    }
    return floatValue;
    }

Is there a way to get this to remove the comma so the figures do not become distorted?

like image 215
Smac Avatar asked Apr 18 '26 10:04

Smac


1 Answers

You could set the useGrouping option to false.

floatValue.toLocaleString(CurrentCulture, { minimumFractionDigits: 2, 
maximumFractionDigits: 2, useGrouping: false });

This should avoid the comma for thousand grouping in english and the dot for thousand grouping in german locale.

like image 144
user3154108 Avatar answered Apr 21 '26 02:04

user3154108



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!