Decimal separator in temperature input
Temperature input does not support both decimal comma and point.
Could this solution be implemented or do you have an easier one:
function realParseFloat(s) { s = s.replace(/[^\d,.-]/g, ''); // strip everything except numbers, dots, commas and negative sign if (navigator.language.substring(0, 2) !== "de" && /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:.\d+)?$/.test(s)) // if not in German locale and matches #,###.###### { s = s.replace(/,/g, ''); // strip out commas return parseFloat(s); // convert to number } else if (/^-?(?:\d+|\d{1,3}(?:.\d{3})+)(?:,\d+)?$/.test(s)) // either in German locale or not match #,###.###### and now matches #.###,######## { s = s.replace(/./g, ''); // strip out dots s = s.replace(/,/g, '.'); // replace comma with dot return parseFloat(s); } else // try #,###.###### anyway { s = s.replace(/,/g, ''); // strip out commas return parseFloat(s); // convert to number } }
@Matsuuu (if you don't want to get tagged in these, let me know)