Do anyone have suggestion for writing culture sensitive ParseFloat Function in JavaScript, So that when I have a string 100,000.22 in US culture format the parse float function returns 100000.22 whereas if I enter 100.000,22 in Swedish Culture it returns 100000.22 in float?
I've improved mwilcox' function to handle values withous separators.
function parseFloatOpts (str) {
if(typeof str === "number"){
return str;
}
var ar = str.split(/\.|,/);
var value = '';
for (var i in ar) {
if (i>0 && i==ar.length-1) {
value += ".";
}
value +=ar[i];
}
return Number(value);
}