jQuery的自动完成的验证输入值 [英] jquery autocomplete that validates entered value

查看:118
本文介绍了jQuery的自动完成的验证输入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery和寻找将支持mustMatch选项(用户必须输入一个存在的项目名称),自动完成 - >这不是一个问题,因为有几个自动完成的这样做结果。
问题是,我需要自动完成将测试输入的值。结果
例如:

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


  1. 用户输入英格兰。

  2. 与英格兰打开列表。

  3. 用户不打表项(不要选择英格兰),但只需点击输入之外。

  4. 支持mustMatch将清除输入,因为用户不从列表中选择最autocompltes。我在找一个自动完成,将验证英伦是否存在,并采取相应的行动。

你知不知道这样的自动完成插件?或者,也许你知道我怎么能修改插件存在这样做?

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

推荐答案

jQueryUI的的自动完成可以沿做到这一点<一个href=\"https://github.com/scottgonzalez/jquery-ui-extensions/blob/master/autocomplete/jquery.ui.autocomplete.autoSelect.js\">Scott冈萨雷斯'自动插件,用变更事件的部件相结合。如果包括插件,你应该需要的是:

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

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

示例: http://jsfiddle.net/qb59C/

这篇关于jQuery的自动完成的验证输入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆