I have a jquery auto complete field and its working properly. Now I want to apply a validation that the field should only accept the value from the suggestion box. In other words user should not be able to input data which is not available in the suggestion box.
Here is my Jquery code
$( "#institutionName" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: instAutocompleteUrl,
dataType: "json",
data: {
searchText: request.term
},
beforeSend: function() {
$("#institutionName").css("background","#FFF url(${resource(dir: 'images', file: '../images/LoaderIcon.gif')}) no-repeat 165px");
},
success: function (data) {
response($.map(data, function (item) {
return {
label: item.Inst_name,
value: item.Inst_name,
id: item.InstID
};
}));
$("#institutionName").css("background","#FFF");
}
});
},
select: function(event, ui ){
console.log(ui);
$('#instId').val(ui.item.id);
}
});