views:

34

answers:

1

Hopefully I am explaining this correctly, I have a long predefined list of items (products in my db) and I would like the user to be able to type and auto complete a product, however if that product / word is NOT in the list, I don't want to allow additional characters to be typed. So the auto complete would ideally block additional input if that input does not exist in the list.

Does something like that exist for the current jQuery UI / jQuery plugin? Or are there mods? I wish to use this method to speed up product selection, but not return a 'not found' page if someone types in something else.

Thank you in advance :)

+1  A: 

This AutoComplete plugin has a function that allows you to test the value to make sure it is in the list.

Robert Harvey
I've looked at this plugin, it however does not limit the user from entering something other than what is in the list, I want something that will 'block' additional input. Otherwise if someone submits the request (for a product) it will return an un-needed not-found forcing the user to either correct or re-type the product.
Jakub
I suppose you can call FindValue() on each keystroke. But it's going to be very slow. If a combo box is out, you need to load up the list into the browser beforehand, so that you don't take the hit from the Ajax call on each keystroke. Some custom coding would be required.
Robert Harvey
findValue() actually is a great solution and I dump all parts into JS array (a lttle crude) then do a simple if in array check. I got the idea from: http://www.ajaxdaddy.com/demo-jquery-autocomplete.html
Jakub