EasyUI Forum

General Category => Bug Report => Topic started by: ClSoft on February 26, 2013, 02:11:08 AM



Title: Number thing
Post by: ClSoft on February 26, 2013, 02:11:08 AM
Hi all
I have this declaration:

<div class="fitem"><label>VAT rate:</label><input class="easyui-numberbox" style="width:100px" name="vat_rate" data-options="precision:2,groupSeparator:'.',decimalSeparator:','"></div>
(groupSeparator is point)

When I enter 1234.99, returned is 123.499,00
If I click inside entry and then I click somewhere else (or I use TAB key) , it become 12.349.900,00 ...


Title: Re: Number thing
Post by: stworthy on February 26, 2013, 07:06:44 AM
Please override the $.fn.numberbox.defaults.parser function to fix this issue.

Code:
$.fn.numberbox.defaults.parser = function(s){
s = s + '';
var opts = $(this).numberbox('options');
if (parseFloat(s) != s){
if (opts.groupSeparator) s = s.replace(new RegExp('\\'+opts.groupSeparator,'g'), '');
if (opts.decimalSeparator) s = s.replace(new RegExp('\\'+opts.decimalSeparator,'g'), '.');
if (opts.prefix) s = s.replace(new RegExp('\\'+$.trim(opts.prefix),'g'), '');
if (opts.suffix) s = s.replace(new RegExp('\\'+$.trim(opts.suffix),'g'), '');
s = s.replace(/\s/g,'');
}

var val = parseFloat(s).toFixed(opts.precision);
if (isNaN(val)) {
val = '';
} else if (typeof(opts.min) == 'number' && val < opts.min) {
val = opts.min.toFixed(opts.precision);
} else if (typeof(opts.max) == 'number' && val > opts.max) {
val = opts.max.toFixed(opts.precision);
}
return val;
};


Title: Re: Number thing
Post by: ClSoft on February 26, 2013, 08:00:04 AM
Thanks.
it is not high important (at this moment) for me, so please tell me would you put that in the next update?
Thanks again.


Title: Re: Number thing
Post by: stworthy on February 26, 2013, 08:08:50 AM
Yes, the parsing logic will be checked carefully and fixed in next version(1.3.3).


Title: Re: Number thing
Post by: ClSoft on February 26, 2013, 08:19:13 AM
Thanks a lot.