jquery autocomplete field that REQUIRES a selected value?

后端 未结 3 1434
一向
一向 2021-01-28 02:01

I need some jquery plugin as they use it on most flight booking sites where you have to choose your departure/arrival airport from a combolist.

i had a look around, but

3条回答
  •  鱼传尺愫
    2021-01-28 02:28

    You have two different questions here.

    Sending hidden IDs should be done using an array of objects with both a value and label attribute in your source. You'll need to use the select and focus options to support this. http://jqueryui.com/demos/autocomplete/#custom-data

    Forcing the user to select a valid option could be done a few ways. I like the idea of blanking the input box if the user types in an invalid option and then leaves the box. You can do this using the "change" option. This is what James' code does too.

    Here is a working example with both features: http://jsfiddle.net/vZeHr/4/

提交回复
热议问题