javascript - jquery autocomplete that validates entered value - Stack Overflow

I am using jquery and looking for a autoplete that will support the mustMatch option (where the user mu

I am using jquery and looking for a autoplete that will support the mustMatch option (where the user must enter an exists item name) -> this is not a problem since there are several autopletes that do so.
The problem is that I need the autoplete will test the entered value.
For example:

  1. The user enters "England".
  2. A list opened with "England".
  3. The user doesn't hit the list item (don't select England), but just click outside the input.
  4. Most autopltes that support mustMatch will clear the input because the user doesn't select from the list. I am looking for an autoplete that will validate whether "England "exists or not and act accordingly.

Do you know such autoplete plugin? Or maybe do you know how can I modify an exists plugin to do so?

I am using jquery and looking for a autoplete that will support the mustMatch option (where the user must enter an exists item name) -> this is not a problem since there are several autopletes that do so.
The problem is that I need the autoplete will test the entered value.
For example:

  1. The user enters "England".
  2. A list opened with "England".
  3. The user doesn't hit the list item (don't select England), but just click outside the input.
  4. Most autopltes that support mustMatch will clear the input because the user doesn't select from the list. I am looking for an autoplete that will validate whether "England "exists or not and act accordingly.

Do you know such autoplete plugin? Or maybe do you know how can I modify an exists plugin to do so?

Share Improve this question edited Mar 17, 2012 at 14:54 Andrew Whitaker 126k32 gold badges295 silver badges308 bronze badges asked Mar 17, 2012 at 14:34 NaorNaor 24.1k50 gold badges156 silver badges270 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

jQueryUI's autoplete can do this along with Scott González' autoSelect plugin, bined with the change event on the widget. If you include the plugin, all you should need is:

$("#auto").autoplete({
    source: ['England', 'Germany', 'Denmark', 'Sweden', 'France', 'Greece', 'Italy'],
    change: function (event, ui) {
        if (!ui.item) {
            this.value = '';
        }
    }
});

Example: http://jsfiddle/qb59C/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743734082a4497936.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信