jQuery UI AutoComplete: Only allow selected valued from suggested list

前端 未结 9 1961
误落风尘
误落风尘 2020-11-30 22:48

I am implementing jQuery UI Autocomplete and am wondering if there is any way to only allow a selection from the suggested results that are

9条回答
  •  情话喂你
    2020-11-30 23:30

    This is how I did it with a list of settlements:

     $("#settlement").autocomplete({
      source:settlements,
      change: function( event, ui ) {
      val = $(this).val();
      exists = $.inArray(val,settlements);
      if (exists<0) {
        $(this).val("");
        return false;
      }
     }
    });
    

提交回复
热议问题