Checks if an item exists in the DB in this case a user.
$(document).ready(function () {
$("#users").fcbkcomplete({
json_url: "yoururl.php",
cache: false,
filter_case: false,
filter_hide: true,
complete_text:"'.get_lang('StartToType').'",
firstselected: true,
onselect:"check_users", //<----- important
filter_selected: true,
newel: true
});
});
Hewe we check if users exists in the DB
function check_users() {
//selecting only "selected" users
$("#users option:selected").each(function() {
var user_id = $(this).val();
if (user_id != "" ) {
$.ajax({
url: "my_other_url_to_check_users.php",
data: "user_id="+user_id,
success: function(return_value) {
if (return_value == 0 ) {
alert("UserDoesNotExist");
}
},
});
}
});
}