I have been working on a tough question and gotten a lot of help from programmers and developers on this site. Many thanks to those who contribute. You are invaluable.
The current condition of my problem is this...
I am attempting to develop a metric to english conversion website that takes a numeric value in a HTML textbox (no form):
I want the user to have multiple ways of entering the data into the conversion tool as it will be used internationally. So...
1,200 or 1.200 or 1200 should all be interpreted by parseFloat as 1200.00
1,200.12 or 1.200,12 or 1200.12 or 1200,12 should all be interpreted as 1200.12.
I would also like decimals to be able to be interpreted.
trim = trim.replace(/[.,](?=.*[.,])/g, "").replace(",", "."); //care of recursive on stack overflow
This seemed to solved the problem with one exception. Anytime data is entered using a thousand separator without using a decimal point this code interprets the separator as a decimal and the value goes from 12,345 to 12.345 or (EU Notation as well). Assuming that the user will use commas but no decimals, this is a troublesome problem as the results will not be correct. How am I to remedy this? Is there an adjustment I can make to the REGEX to have it determine when a comma is a thousand separator (1.234) or a decimal (1,234), or when a period is a thousand separator (1,234) or a decimal point (1.234)?
Thanks in Advance,
©2020 All rights reserved.