Syafiqq / jquery-numberformatter

Automatically exported from code.google.com/p/jquery-numberformatter
0 stars 0 forks source link

Leading zero not displayed in ie #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. browser ie8 
2. use the following code:
$(function(){
$(".amount").live('blur',function(){
$(this).parseNumber({format:"#,##0.00", locale:"nl"});
$(this).formatNumber({format:"#,##0.00", locale:"nl"});
});
});
3. when I leave the input field blank, on blur it will display ',00' instead of 
the expected output '0,00'. It works correct in ff and chrome.

What version of the product are you using? On what operating system?
jquery.numberformatter-1.2.1.js, windows 7, browser ie8

Please provide any additional information below.
The problem is on line 323:
onesFormat.substr(-1,1) => this will return '#' in ie and '0' in chrome or ff 
with the format "#,##0.00"

I replaced it with onesFormat.charAt(onesFormat.length-1) and it worked fine.

Original issue reported on code.google.com by nuyensg...@gmail.com on 11 Jan 2011 at 8:56

GoogleCodeExporter commented 9 years ago
String.substr() with a negative start index does not work in IE, returns an 
empty string:

http://msdn.microsoft.com/en-us/library/0esxc5wy

Original comment by garg...@gmail.com on 15 Feb 2011 at 1:40

GoogleCodeExporter commented 9 years ago
Thanks both, it is indeed a problem with the substr(-1) vs IE.

Original comment by apar...@gmail.com on 13 Apr 2011 at 3:36

GoogleCodeExporter commented 9 years ago
Fixed in repo. Official release to follow this week.

Diff:
323 -           if (!(ones == 0 && onesFormat.substr(-1,1) == '#') || forcedToZero) {
323 +           if (!(ones == 0 && onesFormat.substr(onesFormat.length - 1) == '#') || 
forcedToZero) {

Original comment by apar...@gmail.com on 13 Apr 2011 at 3:48