EasyUI Forum
April 27, 2024, 04:45:56 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Number thing  (Read 13573 times)
ClSoft
Jr. Member
**
Posts: 92


View Profile
« 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 ...
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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;
};
« Last Edit: February 26, 2013, 07:39:52 AM by stworthy » Logged
ClSoft
Jr. Member
**
Posts: 92


View Profile
« Reply #2 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.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: February 26, 2013, 08:08:50 AM »

Yes, the parsing logic will be checked carefully and fixed in next version(1.3.3).
Logged
ClSoft
Jr. Member
**
Posts: 92


View Profile
« Reply #4 on: February 26, 2013, 08:19:13 AM »

Thanks a lot.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!