EasyUI Forum
September 14, 2025, 11:34:46 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: [Solved] validType numeric < = != > etc  (Read 7699 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: April 06, 2016, 07:19:01 PM »

[Solved] How can I set a ValidType on a numberbox / numberspinner that will validate the value i.e:

validType:['value[!=100.222]']
validType:['value[> 1000]']
validType:['value[> 1000 < 2000]']

« Last Edit: April 07, 2016, 02:53:42 AM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 06, 2016, 07:46:09 PM »

Please refer to the following code:
Code:
$.extend($.fn.validatebox.defaults.rules, {
range: {
validator: function(value, param){
value = parseFloat(value);
var min = parseFloat(param[0]);
var max = parseFloat(param[1]);
if (value > min && value < max){
return true;
}
return false;
},
message: 'Invalid number.'
},
notequal: {
validator: function(value, param){
value = parseFloat(value);
var v = parseFloat(param[0]);
return value != v;
},
message: 'The value can not equal to {0}'
}
})
$(function(){
$('#ns').numberspinner({
validType: {
range: [1000,2000],
notequal: [1002]
}
})
})
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #2 on: April 06, 2016, 08:01:37 PM »

Thanks, yes that works, but I was thinking more along the lines of using eval() although I know this function is potentially dangerous.
Logged

-- Licensed User --
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!