EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on February 10, 2015, 09:15:42 PM



Title: switch on and off combobox required [Solved]
Post by: devnull on February 10, 2015, 09:15:42 PM
How can I programmatically switch a combobox between being required and not required.

Code:
      $('#WX').combobox('options').required = true;
      $('#WX').combobox('validate');


Can a method be added to do this ?


Title: Re: switch on and off combobox required
Post by: stworthy on February 11, 2015, 03:42:02 AM
The extended 'required' method of validatebox component can be achieved as below:
Code:
$.extend($.fn.validatebox.methods, {
required: function(jq, required){
return jq.each(function(){
var opts = $(this).validatebox('options');
opts.required = required != undefined ? required : true;
$(this).validatebox('validate');
})
}
})

Usage example:
Code:
$('#WX').combobox('required', false);  // disable required validation
$('#WX').combobox('required');  // enable required validation


Title: Re: switch on and off combobox required
Post by: devnull on February 12, 2015, 03:50:45 AM
Thanks so much, exactly what I was looking for :-)