There's something like this http://docs.jquery.com/Plugins/Autocomplete/autocomplete, but it doesn't force the selection of an item. I need something like this but it has to force an item to be selected before you can "submit".
Any help?
There's something like this http://docs.jquery.com/Plugins/Autocomplete/autocomplete, but it doesn't force the selection of an item. I need something like this but it has to force an item to be selected before you can "submit".
Any help?
Use it in combination with the validation plugin. Just make the field required
for the validation plugin.
This is my solution with .blur (moreover I use name|ID pairs)
jQuery("#username").autocomplete(
"/yii_app/stock/suggestUser",
{
'mustMatch':true,
'multiple':false,
'formatItem':function(result, i, num, term) {
return '<small>'+result[1]+'</small> '+ result[0];
}
}
).result(
function(event,item) {
$("#user_id").val(item[1]);
}
).blur(
function() {
$("#user_id").val('');
$(this).search();
}
);
user_id is a hidden input field, username is an text input field ajax result uses the following format: user1name|user1id\n user2name|user2id\n
Use mustMatch:true, option. This is available in Bassistance autocomplete plugin..i do not know if it is a part of JQuery autocomplete or of bassistance's autocomplete, but it works!