You need to sign in to do that
Don't have an account?

How to replace commas and dots in numbers ?
Hey there !
I'm having trouble converting numbers from US Format to Europe Format.
I want to convert someting like : 1,000,000.555 to 1000000,555
So in an VF Page I have a script and tried this for now doesnt seem to work for the decimal part and i just convert the comma part for thousands :
value = 1,000,000.555
var regex = new RegExp(',', 'g');
value = parseFloat(value.replace(regex,'').replace(/\./g, ','));
the first replace works but not the second one
I would really appreciate some help !
Thanks in advance !
Fadwa.
I'm having trouble converting numbers from US Format to Europe Format.
I want to convert someting like : 1,000,000.555 to 1000000,555
So in an VF Page I have a script and tried this for now doesnt seem to work for the decimal part and i just convert the comma part for thousands :
value = 1,000,000.555
var regex = new RegExp(',', 'g');
value = parseFloat(value.replace(regex,'').replace(/\./g, ','));
the first replace works but not the second one
I would really appreciate some help !
Thanks in advance !
Fadwa.
var regex = new RegExp(',', 'g');
value = parseFloat(value.replace(regex,'').replace(/\./g, ','));
Since value.replace(regex,'').replace(/\./g, ',') gives '1000000,555' , parseFloat on this value will return 1000000
If you want final value from 1000000,555 to 1000000555 then,
var value = '1,000,000.555';
var regex = new RegExp(',', 'g');
value = parseFloat(value.replace(regex,'').replace(/\./g, ',').replace(regex,''));