That was just to exemplify that formatting is not that hard a task. Last time I needed it, I used something like the line below to format the number correctly regardless of locale, removing all but the last separator:
num.replace(/([^\d])(?=\d+[^\d])/g, ''); I'm not sure that will work for every situation. On Jul 6, 9:04 am, Peter Higgins <phigg...@gmail.com> wrote: > "1,200,000.42".replace(',','.') > > >>> 1.200.000.42 > > expected: > 1.200.000,42 > > Unless you aren't using cents, but that seems entirely shortsided. > > Regards, > Peter > > Ricardo wrote: > > Ah. That's a simple case of val.replace(',', '.'). > > parseInt() can handle both, as it ignores the first non-numeric > > character. > > > On Jul 6, 4:16 am, "Anthony Johnston" <anthony.johns...@antix.co.uk> > > wrote: > > >> Apologies for the [spam] marker, its the spam assassin engine being a bit > >> vigorous. > >> Switched it off now > >> Here's what I said, in case it got stopped ... > > >> Don't French/German people enter numbers using a comma for the decimal > >> place? > >> 1,5 == 1.5 > > >> So Number(1,5) should work in a French locale > > >> Ant > > >> -----Original Message----- > >> From: jquery-dev@googlegroups.com [mailto:jquery-...@googlegroups.com] On > > >> Behalf Of Ricardo > >> Sent: 06 July 2009 03:38 > >> To: jQuery Development > >> Subject: [Spam] [jquery-dev] Re: Locale support in jquery > > >> Well.. unless you're using roman numbers or other system a number is a > >> number. The Number() constructor simply converts a string '15' to an > >> integer/float. What impact would locale have on this? > > >> On Jul 4, 6:12 am, "Anthony Johnston" <anthony.johns...@antix.co.uk> > >> wrote: > > >>> Thanks Daniel and Ricardo > > >>> I'll have a look at those. > > >>> So is it the case that js Number() does not support locale input? > > >>> So if you were developing a js calculator for a French/German audience you > >>> would not be able to do > >>> var num = Number($("#Num").val()); > > >>> If this is the case how is it done? > > >>> Ant > > >>> -----Original Message----- > >>> From: jquery-dev@googlegroups.com [mailto:jquery-...@googlegroups.com] On > > >>> Behalf Of Daniel Friesen > >>> Sent: 03 July 2009 22:22 > >>> To: jquery-dev@googlegroups.com > >>> Subject: [Spam] [jquery-dev] Re: Locale support in jquery > > >>> jQuery.ui's datepicker has parse/format support and options can be used > >>> to localize both the datepicker and parsing/formatting. > > >>> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name] > > >>> Ricardo wrote: > > >>>> Not a jQ plugin but worth a good look:http://www.datejs.com/ > > >>>> On Jul 2, 6:45 am, Ant <anthony.johns...@antix.co.uk> wrote: > > >>>>> Hi, > > >>>>> Does jQuery or a plugin provide number and date parsing for the > >>>>> current culture? > > >>>>> There is support in the Microsoft.Ajax library, but I was a bit > >>>>> reluctant to add this to my project as its large and has a lot of > >>>>> overlap with jQuery. > > >>>>> Ta, Ant --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---