Title: numberbox groupSeparator and validator
Post by: Coder on March 31, 2018, 04:52:59 PM
<input id="frmAmount" class="easyui-numberbox" data-options="label: 'Amount' , prompt: 'Amount' , cls: 'r' , groupSeparator: ' ' , precision: 0 , width: 500 , validType:{ greaterThan:[0] ,lessThanOrEqualTo:[1000] } , required: true " > $.extend($.fn.validatebox.defaults.rules, { greaterThan : { validator : function(value, param) { return parseInt(value,10)>parseInt(param[0],10); }, message : 'can be greather then {0}' } , lessThanOrEqualTo : { validator : function(value, param) { return parseInt(value,10)<=parseInt(param[0],10); }, message : 'can be less or equal to {1}' } });
user put 20000 in the lessThanOrEqualTo value = '20 000' and parseInt('20 000',10) == 20 :(
Title: Re: numberbox groupSeparator and validator
Post by: stworthy on April 02, 2018, 01:59:06 AM
Please try to remove the space before parsing the value. lessThanOrEqualTo : { validator : function(value, param) { value = String(value).replace(/ /g,''); var s = String(param[0]).replace(/ /g,''); return parseInt(value,10)<=parseInt(s,10); }, message : 'can be less or equal to {0}' }
|