$(document).ready(function() {
var source = ['Dentist', 'Gynecolist/Obstetrician', 'General Physician', 'Dermatologist/Cosmetologist', 'Ear-Nose-Throat(ent) Specialist', 'Homeopath', 'Ayurveda', 'Thyroid Profile', 'Lipid Profile', 'Complete Blood Count'];
$("input#demo-input-local").autocomplete({
minLength: 0,
source: source,
autoFocus: false,
scroll: true,
}).focus(function() {
$(this).autocomplete("search", "");
}).live("blur", function(event) {
var autocomplete = $(this).data("autocomplete");
var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex($(this).val()) + "$", "i");
autocomplete.widget().children(".ui-menu-item").each(function() {
//Check if each autocomplete item is a case-insensitive match on the input
var item = $(this).data("item.autocomplete");
if (matcher.test(item.label || item.value || item)) {
//There was a match, lets stop checking
autocomplete.selectedItem = item;
return;
}
});
//if there was a match trigger the select event on that match
if (autocomplete.selectedItem) {
autocomplete._trigger("select", event, {
item: autocomplete.selectedItem
});
//there was no match, clear the input
} else {
$(this).val('');
}
});
});