restrict autocmplete's data

restrict autocmplete's data

Hi,

I am using the following code to populate data from MySQL to jquery autocomplete.

is it possible not allow user to write his own company name but only select USING autocomplete so if the company name he entered is not within the list it it won't accept?

  1. $("input#txtCompany").autocomplete
  2. (
  3.     {
  4.         source : function (request, callback)
  5.         {
  6.             var data = { term : request.term };
  7.             $.ajax
  8.             (
  9.                 {
  10.                     url : "../autocomplete_company.php",
  11.                     data : data,
  12.                     search  : function(){$(this).addClass('working');},
  13.                     open    : function(){$(this).removeClass('working');},
  14.                     complete : function (xhr, result)
  15.                     {
  16.                         if (result !== "success") return;
  17.                         var response = xhr.responseText;
  18.                         var autocomplete_result = [];
  19.                         $(response).filter ("li").each (function ()
  20.                         { autocomplete_result.push ($(this).text ());
  21.                     }
  22.                 );
  23.                 callback (autocomplete_result);
  24.             }
  25.         }
  26.         );
  27.     }
  28. });