i have user input containing a number with decimals. i have to modify that input to a format which i can use to do calculations on.
So, consider the following:
input --> should become
10,123.15 --> 10.123,15
10.123,15 --> 10.123,15
10,123.1 --> 10.123,10
10.123,1 --> 10.123,10
10,123 --> 10,123,00
10.123 --> 10.123,00
10.123,13562 --> 10.123,14
10,123.13562 --> 10.123,14
In other words: use dots for thousand separators, comma for decimal separator en always return a rounded up, two decimal number.
I tried using regex'es, substr, round, but i'm kinda stuck. I have it working now for the first two examples mentioned above but now it doesn't work for the rest.
Been looking it at this for a few hours now but maybe you can help me with it? JQuery Number Formatting did help me a bit but still it's not working for all of the examples above.
I would be so happy if someone could help me with this!