Andrew said:
But what happens when someone, from a place where it's normal to use
commas, enters a number with a comma into a field from which I use
javascript to get the value? Do I have to do a conversion like this on it:
num = num ^ "";
num = parseFloat( num.replace(/,/g, ".") );
Something like that. But first you have to spell clearly on the page in
what format do you want to have the number typed. There is nothing
"illegal" to spell your formatting rules. Comma is used as "readability
separator" in the US and as decimal point in some Western countries.
Period used as decimal point in the US and as "readability separator"
in Japan, where period is used as decimal point. Unless you know
exactly that format is used by the customer, any attempt to guess the
entered number is pretty futil. Even if you manage to know the
SystemLanguage, it doesn't prove anything in application to this
particular customer sitting and typing on the computer. So just play
from your side of the table: "please inter the numbers in this format:
XXXXX and I don't give a damn what you've been thaught in your damn
local school"
Obviously the required format should be as used by
the majority of the expected customers. If you cannot determine such
majority, then drop a coin.