mzeezimu / jquery-numberformatter Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/jquery-numberformatter
Automatically exported from code.google.com/p/jquery-numberformatter
PL (Polish) locale is same as FR (123 456,78), so quick fix will be:
var nfLocalesLikeFR = [ 'cz','fi','fr','ru','se','pl' ];
Original issue reported on code.google.com by [email protected]
on 7 Sep 2010 at 2:03
Maybe I'm just using it the wrong way, but this plugin does not work for me at
all. A few examples, tested on version 1.1.0:
A) $.formatNumber() does not work at all:
1. $.formatNumber(123456.789, {format: "#,##0.0", locale: "us"})
2. expected result: "123,456.8"
3. actual result "123456.789"
B) Dosn't work with other locales, either:
1. $.formatNumber(123456.789, {format: "#,##0.0", locale: "de"})
2. expected result: "123.456,8"
3. actual result "123456,789"
C) Formatting a number in an element also does not work:
1. $("<span>123456.789</span>").format({format: "#,##0.0", locale: "de"}).text()
2. expected result: "123.456,8"
3. actual result "123.456.789,0"
D) And also:
1. $("<span>0</span>").format({format: "#", locale: "us"}).text()
2. expected result: ""
3. actual result: "0"
It looks like this plugin has some serious issues.
I can understand, to a certain extent, that in C) the plugin expects the text
value to be in the locale I ask for (maybe I should be able to specify an
inputLocale parameter?).
Anaway that's the case $.formatNumber() should be able to handle, only that
this function does not do anything useful at all. Looking at its
implementation, it should be renamed to formatString() or something, because
formatting a number is certainly not what it does. ;-)
Original issue reported on code.google.com by [email protected]
on 16 Aug 2010 at 12:22
What steps will reproduce the problem?
1. If i intro "hello"
2. I get "Nan.Nan"
3. Is posible to get "0.00" instead of Nan.Nan?
Original issue reported on code.google.com by [email protected]
on 8 Jul 2010 at 4:04
What steps will reproduce the problem?
1. enter the number 1000000.12345 to an input with id="elemId"
2. call format function for the input like this:
$("#elemId").format({format:"###,##0.00###"});
What is the expected output?
1,000,000.12345
What do you see instead?
1,000,000.123
What version of the product are you using?
1.1.0 with jquery 1.3.2
On what operating system?
red hat 5 with firefox 3.
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 15 Feb 2010 at 5:38
What steps will reproduce the problem?
1. Set format pattern "#,###.###".
javascript code example is this.
$('#forms1').format({format:"#,###.###", locale:"jp"});
2. Write input field with value "3456.00".
html code example is this.
<input name="textfield" type="text" id="forms1" maxlength="20"
value="333333.0000000">
3. Formatted value "3,456." is displayed.
What is the expected output? What do you see instead?
I want to display "3,456" in textfield.
What version of the product are you using? On what operating system?
Windows Vista
Internet Explorer 7
jquery 1.3.1
jquery.numberformatter.js 1.1.1
Please provide any additional information below.
I needed decimalSeparatorAlwaysShown flag,
such as decimalSeparatorAlwaysShown flag in Java SDK java.text.NumberFormat.
(here from
http://java.sun.com/j2se/1.5.0/docs/api/java/text/NumberFormat.html)
decimalSeparatorAlwaysShown : only affects formatting, and only where
there might be
no digits after the decimal point, such as with a pattern like
"#,##0.##", e.g.,
if true, 3456.00 -> "3,456." if false, 3456.00 -> "3456"
And then, I implemented decimalSeparatorAlwaysShown flag in this
numberformat library.
Please check this code, and Would you take patch into
jquery-numberformatter code ?
Original issue reported on code.google.com by advweb.nanasi.jp
on 11 Mar 2009 at 5:26
Attachments:
[deleted issue]
What steps will reproduce the problem?
1. User inputs number with more than one group separator (e.g. 5,000,000)
2. Call "format" function
3. Notice that you get a "NaN"
What is the expected output? What do you see instead?
I expect to get back "5,000,000" (or whatever, based on format string). Instead
I'm getting NaN.
What version of the product are you using? On what operating system?
Firefox 3.0.7, Mac OS X 10.4.11
Please provide any additional information below.
The "text.replace(group,'')" only removes the first instance of the grouping
separator. It should
remove all of them. See attached for a patch.
Original issue reported on code.google.com by [email protected]
on 11 Mar 2009 at 4:45
Attachments:
What steps will reproduce the problem?
var fakediv= $("<div>");
fakediv.html(0.026030368763557687);
fakediv.format({format:"#,###.00", locale:"de"});
What is the expected output? What do you see instead?
0,02 but i get: 26.030.368.763.557.690,00
What version of the product are you using? On what operating system?
1.1.2 windows/firefox 3.6
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 13 Aug 2010 at 11:56
What steps will reproduce the problem?
1. Create a test page referencing jquery and the latest numberformatter
2. add the following to the html:
<div id="test">-434.4343</div>
<script type="text/javascript">
$("#test").format({format:"-#,###.00", locale:"us"});
</script>
What is the expected output? What do you see instead?
I expected the output to read "-434.43". Instead I see "-,434.43".
What version of the product are you using? On what operating system?
jquery 1.3.1, numberformatter 1.1.0, windows server 2008
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 4 Feb 2009 at 9:58
What steps will reproduce the problem?
1. Add an input field. Value: "0,998"
2. Format with NumberFormatter using "0.00" as format, locale "de" (US
locale should have the same problem)
3.
What is the expected output?
"1,00"
What do you see instead?
"0,00"
What version of the product are you using? On what operating system?
1.1.2
Code lines 294 ff do not take add carry into account.
Therefore, nearly useless plugin.
Original issue reported on code.google.com by [email protected]
on 24 Nov 2009 at 9:50
What steps will reproduce the problem?
1. Set percent format on blur ("#.0%").
2. Enter any numeric value and than lose the focus.
3. Set the focus again and lose it again.
What is the expected output? What do you see instead?
Expected formatted value with % postfix.
Instead we can see: NaN,N%
What version of the product are you using? On what operating system?
v. 1.1.2, OS Win XP SP3
Please provide any additional information below.
jQuery.fn.format failed.
Line 249: var number = new Number(text.replace(dec,".").replace(neg,"-"));
Original issue reported on code.google.com by [email protected]
on 13 Oct 2009 at 5:49
Add it in the same "if" expression as Brazil "br":
if (
...
locale == "br" ||
locale == "pt"
)
{
dec = ",";
group = ".";
}
Original issue reported on code.google.com by rgl%[email protected]
on 25 Jan 2010 at 11:00
What steps will reproduce the problem?
1. entering negative number to the field
2.
3.
What is the expected output? What do you see instead?
I see NaN instead -1234
What version of the product are you using? On what operating system?
Last version, winXp
Please provide any additional information below.
I tried to format with
$("#field").format({format:"-#,###,###", locale:"hu"}); doesn't help.
Original issue reported on code.google.com by [email protected]
on 22 Jan 2009 at 3:30
else if (locale == "de" ||
locale == "vn" ||
locale == "es" ||
locale == "dk" ||
locale == "at" ||
locale == "gr" ||
locale == "br" ||
locale == "it"
)
{
dec = ",";
group = ".";
}
Original issue reported on code.google.com by [email protected]
on 21 Sep 2009 at 11:16
In The Netherlands (Holland) for currencies we use a dot as the thousands
separator, e.g. EUR 1.234.567,89
But for other numbers a (narrow) space is used, e.g. 1 234 567,89
For more info and other countries (to make the list complete):
http://en.wikipedia.org/wiki/Decimal_separator#Arabic_numeral_system
Original issue reported on code.google.com by [email protected]
on 19 Feb 2009 at 11:09
What steps will reproduce the problem?
<html>
<head>
</head>
<body>
<script src="jquery-1.2.6.js" type="text/javascript"></script>
<script src="jquery.numberformatter.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery('span').format({format:"#,##0.00 EUR", locale:"de"});
});
// document.writeln("Number: " + jQuery.format({format:"#,###.00",
locale:"de"}));
</script>
</body>
<span>10000.1</span>
</html>
What is the expected output? What do you see instead?
Expected: 10.000,10 EUR
Actual: 100.001,00 EUR
What version of the product are you using? On what operating system?
1.1.2 on Windows
Please provide any additional information below.
In US locale it works correctly
Original issue reported on code.google.com by [email protected]
on 23 Apr 2009 at 11:59
$('<p>1</p><p>2</p><p>3</p>').format({format:'Price: #,###.00 €'})
will output:
<p>Price: 1.00 €</p><p>2.00</p><p>3.00</p>
where it should be:
<p>Price: 1.00 €</p><p>Price: 2.00 €</p><p>Price: 3.00 €</p>
Solution:
Move lines 215-243 before line 209 (return each...)
Regards, Blaz
Original issue reported on code.google.com by [email protected]
on 12 May 2010 at 5:17
What steps will reproduce the problem?
1. Select a group of elements to format
2. Observe that the format is correctly applied to the first match
3. Observe that it's not for the subsequent matches.
Example:
<table>
<tr><td class="money">2.5</td></tr>
<tr><td class="money">2.5</td></tr>
<tr><td class="money">2.5</td></tr>
<tr><td class="money">2.5</td></tr>
</table>
<script type="text/javascript">
jQuery('td.money').format({format:'$#,###.00',locale:'us'});
</script>
Expected output:
$2.50
$2.50
$2.50
$2.50
Actual output:
$2.50
2.50
2.50
2.50
(Note that part of the format works, but the $ part is lost after the first
value).
Original issue reported on code.google.com by [email protected]
on 11 Feb 2010 at 7:19
What steps will reproduce the problem?
1. Fill a "lire" input with the value of a "euro" input (two textbox).
2. txtEuro is $("#txtEuro") and txtLire is $("#txtLire")
3. I use this:
function calculateLire(txtEuro, txtLire) {
var euro = $(txtEuro).parse({ locale: "it" });
if (euro == 0) {
$(txtLire).val(0);
}
else {
$(txtLire).val((euro * 1936.27));
// at this point txtLire contain a correct value ("us" formatted)
$(txtLire).format({ format: "#.000", locale: "it" });
}
}
Locale "it" have dec="," , group="." like "de"
What is the expected output? What do you see instead?
with "1" in txtEuro I have 193627,000.
Correct string is 1936,270 .
I also try this trick:
$(txtLire).format({ format: "#.000", locale: "us" });
$(txtLire).format({ format: "#.000", locale: "de" });
but not does what I want...
How can I use this plugin for obtain the right result?
What version of the product are you using? On what operating system?
version 1.1.2 (on Windows XP, Firefox and Maxthon)
Please provide any additional information below.
I think the problem is on format function:
// now we need to convert it into a number
while (text.indexOf(group) > -1)
text = text.replace(group, '');
the number 1936.27 become 193627 here...
bye
Alessandro
Original issue reported on code.google.com by alessandro.piccione.75
on 23 Jun 2009 at 11:05
What steps will reproduce the problem?
1. Format "00"
2. Number is "3"
3. format should return "03"
Can a format for leading zeros be specified?
Original issue reported on code.google.com by [email protected]
on 25 Mar 2010 at 1:54
One line of code was enough...
I've added the line :
locale == "tr" ||
to this part of your code...
Thanks for writing this useful code...
-------
else if (locale == "de" ||
locale == "vn" ||
locale == "es" ||
locale == "dk" ||
locale == "at" ||
locale == "gr" ||
locale == "tr" ||
locale == "br"
)
{
dec = ",";
group = ".";
}
---------
Original issue reported on code.google.com by [email protected]
on 1 Jun 2009 at 10:39
Attachments:
What steps will reproduce the problem?
1. enter 1,9999 into the txtAmount textbox
2. $("#txtAmount").format({format:"#.00",locale:'nl'});
What is the expected output? What do you see instead?
- expected: 2,00
- I see 1,00
What version of the product are you using? On what operating system?
1.1.2 (OS = windows)
Original issue reported on code.google.com by [email protected]
on 18 Jan 2010 at 10:24
What steps will reproduce the problem?
1. Apply the number format (#,###)
2. Apply the number format again (#,###)
3. Results in NaN on a number like 1,234,567
What is the expected output? What do you see instead?
Should not do anything.
What version of the product are you using? On what operating system?
1.1.0
Please provide any additional information below.
Using along with tablesorter. If I sort twice, results in the NaN on large
numbers.
Original issue reported on code.google.com by [email protected]
on 27 May 2010 at 11:29
It would be good if this also provided an option for adding ordinal
suffixes to numbers.
Original issue reported on code.google.com by [email protected]
on 16 Apr 2010 at 2:23
What steps will reproduce the problem?
1. format: #,###.00、local:us
2. test number: 4.9999
3. result:4.0
What is the expected output? What do you see instead?
5.0
What version of the product are you using? On what operating system?
jquery.numberformatter-1.1.2.js
Please provide any additional information below.
Separately calculate integer and decimal places
Original issue reported on code.google.com by [email protected]
on 12 Mar 2010 at 5:35
What steps will reproduce the problem?
1. Create input field with "5000000.56789" value.
Sample html code is this.
<input type="text" value="5000000.56789" size="50" id="target" />
2. Use jquery.numberformatter-1.1.1.js, and
format text value with "#,###.###" pattern. ("dec" is "." in locale:jp)
Sample javascript code is this.
$('#target').format({format:"#,###.###", locale:"jp"});
3. "5,000,000.5" is displayed in textfield.
Neither "5,000,000.567" and "5,000,000.568" is displayed.
What is the expected output? What do you see instead?
"5,000,000.567", or "5,000,000.568" are displayed in textfield.
What version of the product are you using? On what operating system?
Windows Vista
Internet Explorer 7
jquery 1.3.1
jquery.numberformatter.js 1.1.1
Please provide any additional information below.
I found javascript code problem.
Please check my posting patch, and Would you fix your
jquery.numberformatter.js library code ?
Original issue reported on code.google.com by advweb.nanasi.jp
on 12 Mar 2009 at 1:05
Attachments:
If someone enters a number that is not supported by the current locale (e.g.
"45,3" instead of
"43.3") the resulting string will be "NaN.Na". This is a bit ugly. Maybe it
would be better to do
nothing instead, just return the original string...
Original issue reported on code.google.com by [email protected]
on 13 Aug 2009 at 12:59
What steps will reproduce the problem?
1. call $.formatNumber with a number and formatting options
What is the expected output? What do you see instead?
A formatted string (12345->12,345, I get 12345)
What version of the product are you using? On what operating system?
1.1.0
Please provide any additional information below.
I extracted the code that actaully does the formatting from $.fn.format
and created a new formatNumber method that is called by $.fn.format for
each JQuery object, but can also be called for any string representing a
number.
I didn't see the point in keeping the old formatNumber method (it should
probably be renamed to represent what it does, which is convert to locale)
jquery objects aren't the only way you might want to use this
functionality, I needed this change to support number formatting in
JavaScript Templates.
another small issue, $.format and $.parse are a generic names that are
used by other unrelated plugins, it should probably be named
$.formatNumber and $.parseNumber to avoid conflicts with other plugins
Original issue reported on code.google.com by [email protected]
on 24 Mar 2009 at 5:36
Attachments:
What steps will reproduce the problem?
1. make the script to run when onblur (just like the example)
2. enter non numeric entry
3. the value will be NaN.NaN
What is the expected output? What do you see instead?
0 (zero), for certain people, make it zero is more reasonable than NaN.NaN
What version of the product are you using? On what operating system?
NumberFormatter version 1.1.2 (dated 2/6/08)
Please provide any additional information below.
you can add this line of code at line 241 just after the var number = new
Number(text.replace(dec, ".").replace(neg, "-")); code.
here is the code to force it to 0 if NaN value produced.
if (isNaN(parseFloat(number))) number = 0;
Original issue reported on code.google.com by [email protected]
on 12 Nov 2009 at 12:55
Attachments:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.