How to limit the number of results in jQuery autocomplete?

autocomplete, jquery

Solution

Unfortunetely there is no bulit in property to set max limit. You can use:

$("#autocmplt").autocomplete({
source: function(req, response) {
    var results = $.ui.autocomplete.filter(myarray, req.term);

    response(results.slice(0, 5));//for getting 5 results
   }
});

Working Demo

Problem

I have searched enough, but am not able to find the solution to this. Could you please help me out. I have a table which has around 700 records, and I want the autocomplete to display not more than 5 records in the result. It should have a scroll bar.

Original source

Related problems