Closed GoogleCodeExporter closed 8 years ago
[deleted comment]
Making a mess of it. Now the correct diff
Original comment by macjo...@gmail.com
on 14 Nov 2012 at 2:45
Attachments:
New version fixing the hasPercent variable (which should be tested for first...)
Note that I haven't tested this with negative formats like -$23.32
Original comment by macjo...@gmail.com
on 14 Nov 2012 at 3:23
Attachments:
Not quite sure I am reproducing it the same as you, but this is already
supported functionality that appears to work ok -
var result = $.formatNumber(100, {format: '#,##0 m2', locale: 'en'});
produces result = "100 m2"
perhaps I am missing something?
Original comment by apar...@gmail.com
on 22 Oct 2013 at 12:22
Hi,
I've tested your current script with my form.
The setting is as follows:
I have an input field where users can enter the m2 area of their house. The
number (eg. 100) is then formatted to "100 m2" on the javascript onBlur.
When the user re-enters the input field and leaves, the formatting is done
again resulting in:
first time: "1002 m2"
2nd tim: "10022 m2"
etc.
So the issue isn't the first formatting sequence, but the next.
Original comment by joost.de...@gmail.com
on 22 Oct 2013 at 1:03
Ah yes, the problem is to do with the parse and not the format.
To better allow prefix ignoring when parsing, I've added a option on the parse
called 'allowPostfix' which will truncate the input string as soon as it hits
something unexpected (space in this example)
which works as follows -
var result = $.parseNumber('100 m2', {format: '#,##0 m2', locale: 'en',
allowPostfix: true});
// result == '100'
result = $.formatNumber(result, {format: '#,##0 m2', locale: 'en'});
// result == '100 m2'
Which I think solves this issue whilst breaking no existing default
functionality.
SVN updated and will be included in the 1.2.4 release.
Original comment by apar...@gmail.com
on 22 Oct 2013 at 1:23
Original issue reported on code.google.com by
macjo...@gmail.com
on 14 Nov 2012 at 2:40