jquery ui - How to prevent use from putting non valid value in the autocomplete field? -
how prevent user inserting value not in source of autocomplete?
var items= [ { "label": "account administration" }, { "label": "applications"}, { "label": "general information" }, { "label": "hardware" }, { "label": "network" }, { "label": "operating system" }, { "label": "remote connectivity" } ]; $(".autocomp").autocomplete({ source: items});
well while coming example figured out.
$(".autocomp").blur( function(event){ s = this.value.touppercase(); var r = ""; for(var i=0;i<items.length; i++) { if(s===items[i].label.touppercase()){ r= items[i].label; break;} } this.value=r; });
http://jsfiddle.net/daelectric/bspn2/
but there better way of doing this?
Comments
Post a Comment