javascript - jQuery autocomplete validation -


i using jquery autocomplete list of 800 values

    j$(function() {     var availabletags = [item1,item2, item3,...];     j$( "#stdcodes" ).autocomplete({     source: availabletags     }); }); 

this works fine, want limit or validate input in 1 autocomplete values.

can this?

try this:

$("#stdcodes").autocomplete({     open: function(e) {        valid = false;      },      select: function(e){         valid = true;      },      close: function(e){          if (!valid) $(this).val('');      },      source: availabletags });  $("#stdcodes").change(function(){     if (availabletags.indexof($(this).val()) == -1){         $(this).val("");     } }); 

added validation, in case autocomplete doesn't execute

fiddle:

http://jsfiddle.net/ra96r/2/


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -