EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: kingor2001 on June 21, 2019, 11:03:27 AM



Title: validType:'length[0,10]' is invalid for tagbox?
Post by: kingor2001 on June 21, 2019, 11:03:27 AM
validType:'length[0,10]' is invalid for tagbox?
such as <input class="easyui-tagbox" data-options="label:'foo',validType:'length[1,2]'">, the length[1,2] is invalid.


Title: Re: validType:'length[0,10]' is invalid for tagbox?
Post by: jarry on June 22, 2019, 06:50:22 AM
You should custom a validation rule for the tagbox.
Code:
$.extend($.fn.validatebox.defaults.rules, {
taglength: {
validator: function(value,param){
value = $.trim(value).replace(/\,$/,'');
var len = $.trim(value).split(',').length;
return len >= param[0] && len <= param[1]
},
message: 'Please enter a value between {0} and {1}.'
}
})