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:
Comments
Post a Comment