sansanbgl / jquery-formatcurrency

Automatically exported from code.google.com/p/jquery-formatcurrency
GNU General Public License v3.0
0 stars 0 forks source link

Not working right when theres no currency symbol, '.' is digital grouping and ',' is decimal delimiter. #21

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If you put theese settings

$.formatCurrency.regions[''] = {
        symbol: '',
        positiveFormat: '%n',
        negativeFormat: '-%n',
        decimalSymbol: ',',
        digitGroupSymbol: '.',
        groupDigits: true
    };

after hitting 4 digits result is
123.4

but after hitting fifth digit it's
123,45
and then starts the decimal warning and it's not the same number anymore.

I am reffering at this example
http://bendewey.com/code/formatcurrency/demo/format_as_you_type.html
round to 2 decimal places as you type

I am using last version 1.4.0 on windows 7 and XP.

Original issue reported on code.google.com by woo...@gmail.com on 5 Aug 2010 at 7:20

GoogleCodeExporter commented 8 years ago
Greetings,

We were experimenting the same issue and resolved it by removing the following 
if statement (keep the code inside):

// if the number is valid use it, otherwise clean it
if (isNaN(num)) {
  ...
}

Although this solution worked for us, we are unsure if this fix will cause 
problems with other regions and we encourage further testing.

Note for the author: In a (more or less) few words, the problem occurs when you 
got no symbol defined or its empty and the digitGroupSymbol is not the default 
[,]. 

When these conditions are satisfied, isNaN(num) will return true either when 
the symbol is supplied OR (if you choose to omit the symbol or supply a blank 
one), the digitGroupSymbol equals the arithmetic one [,] (since 1,0000 is not 
considered a number while 1.0000 is), therefore running the much needed RegExp 
cleanup expression for the number.

Cheers and thanks the author for this great plugin.

Original comment by sot...@gmail.com on 6 Oct 2010 at 8:36

GoogleCodeExporter commented 8 years ago

Original comment by bdewe...@hotmail.com on 3 Oct 2011 at 1:44