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

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -