EasyUI Forum
March 28, 2024, 07:38:11 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: numberbox groupSeparator and validator  (Read 5646 times)
Coder
Jr. Member
**
Posts: 92


View Profile
« on: March 31, 2018, 04:52:59 PM »

Code:
<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
"
>

Code:
$.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
 Sad
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 02, 2018, 01:59:06 AM »

Please try to remove the space before parsing the value.
Code:
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}'
}
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!