PDA

View Full Version : NumberField, decimalSeparator and parseValue



FritFrut
5 Nov 2007, 3:47 PM
The documentation for Numberfield says:


decimalSeparator : String
Character(s) to allow as the decimal separator (defaults to '.')

which means that more than one character can be used as a separator. Specifying

decimalSeparator: ".,"
works for input, however, in parseValue

return parseFloat(String(value).replace(this.decimalSeparator, ".")) || '';
the whole decimalSeparator string is replaced by a '.', and not each character.

mystix
5 Nov 2007, 7:14 PM
:-?

1 question: what's the use case for having a separator of '.,' ?

FritFrut
5 Nov 2007, 9:02 PM
:-?

1 question: what's the use case for having a separator of '.,' ?

Some of my users have US keyboard, some have Croatian.

If you press key '.' on numeric keyboard with US layout, it will emit the '.' character, but on Croatian it will be ','. So, it's easier to allow both.

Cheers, Tom

tryanDLS
6 Nov 2007, 11:09 AM
Those are still single characters, which is what the property is intended for - it's not a list of characters. Shouldn't you be handling this thru a translation file - I would think that you have more issues than just this single character.

FritFrut
6 Nov 2007, 11:28 AM
Those are still single characters, which is what the property is intended for - it's not a list of characters. Shouldn't you be handling this thru a translation file - I would think that you have more issues than just this single character.
Hm, perhaps you misunderstood me... I'd like to use both 123.45 and 123,45 as a valid float number. So, I hoped that specifying '.,' as a separator would treat it as a list of valid separator characters.

What issues? I don't see any... in fact, I've been using this approach in many applications and it usually worked.

It's not that important, I could hack something, but it would be nice to have. Anyway, in this case, documentation should be changed, because it's misleading.

Cheers, Tom