EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: joe on April 13, 2017, 07:33:22 PM



Title: Numberbox validation event?
Post by: joe 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...


Title: Re: Numberbox validation event?
Post by: jarry 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]',
    //...
  }
}


Title: Re: Numberbox validation event?
Post by: joe 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.


Title: Re: Numberbox validation event?
Post by: jarry on April 17, 2017, 05:09:45 PM
Please look at this example http://code.reloado.com/anorag4/edit#preview. It works fine.