locbet / jquery-numberformatter

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

Convertion from Lire to Euro with custom format #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
I make this change in format function, and it works for me:

                /// CHANGE (Alessandro): this code treat string like a formatted 
one, but I WANT to format an unformatted one
                // now we need to convert it into a number
                //                while (text.indexOf(group) > -1)
                //                    text = text.replace(group, '');
                //                var number = new Number(text.replace
(dec, ".").replace(neg, "-"));

                //while (text.indexOf(group) > -1)
                //    text = text.replace(group, '');
                //var number = new Number(text.replace(dec, ".").replace(neg, "-"));

                var number = new Number(text);

Alessandro

Original comment by alessandro.piccione.75 on 23 Jun 2009 at 11:24

GoogleCodeExporter commented 8 years ago
Issue seems to have been resolved with next release (1.2 - due soon).

Original comment by apar...@gmail.com on 5 Feb 2010 at 7:01