jEasy ComboBox Demo
Show's result of setting non-valid ID, and validation of that value.
HTML
<link rel="stylesheet" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<script src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<div>
<label >Phone:</label>
<input class="easyui-combobox" id="Phone" name="Phone" />
</div>
JavaScript
$(function () {
$('#Phone').combobox({
panelHeight: 'auto',
valueField: 'id',
textField: 'text',
editable: true,
multiple: true,
data: [{"id":"0","text":"Motorola","id":"10","text":"Benq","id":"11","text":"Sony"},{"id":"1","text":"Nokia"},{"id":"2","text":"Xiaomi"},{"id":"3","text":"LG"},{"id":"4","text":"HTC"},{"id":"6","text":"Samsung"}],
inputEvents: $.extend({}, $.fn.combobox.defaults.inputEvents, {
blur: function(e){
var target = e.data.target;
var rows = $(target).combobox('getData');
var vv = [];
$.map($(target).combobox('getValues'), function(v){
if (getRowIndex(target, v) >= 0){
vv.push(v);
}
});
$(target).combobox('setValues', vv);
function getRowIndex(target, value){
var state = $.data(target, 'combobox');
var opts = state.options;
var data = state.data;
for(var i=0; i<data.length; i++){
if (data[i][opts.valueField] == value){
return i;
}
}
return -1;
}
}
})
});
});