Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Devbridge autocomplete - Force selection from list

I am using DevBridge jQuery auto-complete, which is working fine but I want to force the user to select an option from the drop down list.

Is there any way to do this?

var airports = [
    { value: 'Manchester (MAN)' },
    { value: 'Bangkok (BKK)' }, 
    { value: 'New York (JFK)' }
];

$('#autocomplete').autocomplete({
    lookup: airports
});
like image 486
User787665 Avatar asked Oct 31 '22 07:10

User787665


1 Answers

The function I've used is onInvalidateSelection

$("#MyField").autocomplete({
    onInvalidateSelection:function(){
        $("#MyField").val("");
    }
});

That's what worked best for me.

like image 136
Javier Avatar answered Nov 08 '22 16:11

Javier