Let try:
First extend check validation to check when user key in.
$.extend($.fn.validatebox.defaults.rules, {
check: {
validator: function(value,param){
var obj = $(param[0]).combobox('getData');
var arr = [],n,result;
arr = $.map(obj,function(n,i){ n = n.textfield || n.text ; return n; });
result = jQuery.inArray(value, arr);
if(result == -1) return false;
else return true;
},
message: 'Please fill it correctly!'
}
});
Add
validType="check['#company_name']"
to your combobox.
Define id=0 to your default text "- Select City -"
In my case i load data from server so i will do like:
$item = array('id'=>'0','text'=>'- Select City -');
$result = array();
array_push($result, $item);
For form submit:
$('#fm').form('submit', {
url: savedata_url,
onSubmit: function(param) {
if ($('input[name=city_name]').val() === '0') {
msg = 'Please select City!';
$.messager.alert('Confirm', msg, 'info');
return false;
} else
return $(this).form('validate');
},