jQuery的自动完成:确定输入的文字不匹配 [英] jQuery Autocomplete: Determining if entered text is not a match

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

问题描述

我有jQuery的自动完成(UI 1.6rc2)并运行良好,当用户拿起一个项目,它更新与相关ID的隐藏的表单值。如何设置隐藏的表单值设为0时输入从自动完成列表中的结果不匹配的文本?在这种情况下,我将创建一个新的条目。

I've got jQuery Autocomplete (UI 1.6rc2) up and running fine and when the user picks an item, it updates a hidden form value with the associated ID. How do I set the hidden form value to '0' when the text entered does not match a result from the autocomplete list? In this case, I'll be creating a new entry.

推荐答案

我的自动完成功能这样做:

I did this in the autocomplete function:

change: function(event, ui){
   $(this).next("input[id^=person_id]").val('');
  return false;

用户选择的选项,它填充我的隐藏的输入与项目ID,如果有变更,以可见光输入

后,将隐藏的输入值被清除。就像一个魅力!

After the user selects the option and it populates my hidden input with the item ID, if any changes occur to the visible input, the hidden input value is cleared. Works like a charm!

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

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