텍스트 상자에 대한 jquery 자동 완성은 자동 완성 목록 이외의 데이터를 허용해서는 안됩니다.하지만 문제는 목록 자동 완성 목록의 데이터 만 허용해야합니다. 사용자가 다른 데이터를 입력하더라도 자동 완성 목록에서 선택하는 메시지를 표시해야하는 다른 모든 데이터텍스트 상자에 대한 jquery 자동 완성은 자동 완성 목록 이외의 데이터를 허용해서는 안됩니다.
아래 또한 자동 완성 제안보다 데이터를 다른 허용하고 링크 쇼 :
$("#field").autocomplete({
source: countries_starting_with_A,
minLength: 1,
select: function(event, ui) {
// feed hidden id field
$("#field_id").val(ui.item.id);
// update number of returned rows
$('#results_count').html('');
},
open: function(event, ui) {
// update number of returned rows
var len = $('.ui-autocomplete > li').length;
$('#results_count').html('(#' + len + ')');
},
close: function(event, ui) {
// update number of returned rows
$('#results_count').html('');
},
// mustMatch implementation
change: function (event, ui) {
if (ui.item === null) {
$(this).val('');
$('#field_id').val('');
}
}
});
http://jsfiddle.net/handtrix/32Bck/
도움을 주셔서 감사합니다. makeSelect = true를 사용하면 요구 사항이 잘 작동합니다. – ManiShankar