I have an input field that is formatted using .toLocaleString()
.
Then I need to use parseFloat()
on that value to convert it to a number.
To do this with a US locale, I simply use value.replace(',','')
to strip out the decimals before executing the parseFloat()
.
However this doesn't work in European locales in which the thousand separators and decimal points are inverted.
Is there a method of determining which locale your user is in and then whether to invert commas and decimals first?