Limit Results in Jquery ui autocomplete

In this article, you will see how to limit results in jquery ui autocomplete.

Enter the limit in the following textbox to display results.

Max Results :

Now the below text box will display the following results.
Java, J2ee, Spring, Hibernate, Struts, Css, Maven, Spring Roo, Struts 2, Maven 2, EJB, JSF, JSF 2.0

Results : Try this

Following code is used to limit the size.

var testdata=["Java","J2ee","Spring","Hibernate","CSS","HTML","Struts","Struts 2","Maven","Maven 2","Spring Roo","JSF","JSF 2.0","EJB"];
        minLength: 1,source: function(request, response) {
        var results = $.ui.autocomplete.filter(testdata, request.term);
        response(results.slice(0, 5));

No comments yet.

Leave a Reply