EasyUI Forum
June 26, 2024, 12:55:18 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: Numberbox validation event?  (Read 6225 times)
joe
Newbie
*
Posts: 33


View Profile Email
« on: April 13, 2017, 07:33:22 PM »

I used a numberbox in a edatagrid.  I also set a max/min range.  If a user enter a number outside of that range, the number box automatically correct it by changing the user's input to one of the border number (max/min).  Is there a way to stop that from happening and just popup a message letting the user know that they have entered a number outside of the range?

Thanks...
Logged
jarry
Administrator
Hero Member
*****
Posts: 2267


View Profile Email
« Reply #1 on: April 14, 2017, 06:53:08 PM »

Please extend a 'range' validation rule.
Code:
$.extend($.fn.validatebox.defaults.rules,{
range: {
validator: function(value,param){
var min = parseInt(param[0]);
var max = parseInt(param[1]);
return value>=min && value<=max;
},
message: 'The value must be between {0} and {1}'
}
})

And then apply it to the numberbox editor.
Code:
editor:{
  type:'numberbox',
  options:{
    validType:'range[10,20]',
    //...
  }
}
Logged
joe
Newbie
*
Posts: 33


View Profile Email
« Reply #2 on: April 17, 2017, 11:05:34 AM »

Thanks for the solution.  The range extension works great.  However, the "message" is not showing up in my edatagrid.  The editable numberbox field turns red but the message is not there.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2267


View Profile Email
« Reply #3 on: April 17, 2017, 05:09:45 PM »

Please look at this example http://code.reloado.com/anorag4/edit#preview. It works fine.
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!