【问题标题】:jQuery Autocomplete Validation - How to make a selection required?jQuery 自动完成验证 - 如何进行选择?
【发布时间】:2011-06-15 02:28:07
【问题描述】:

我在文本框上使用 jQuery 自动完成功能,以便用户可以选择交易。我需要将此作为必填字段。我也在使用 jQuery 验证。

这是我的自动完成 cpde:

$(\"#trade\").autocomplete({
    source: " . $tradeString . ",
    maxHeight:100,
    autoFill: true,
    minLength: 3,
    close: function() { $(\"#form\").validate().element(\"#trade\"); }
}).select(function() {
    $(this).autocomplete(\"search\");
});

这是我的 jQuery 验证代码:

$("#form").validate({   
    errorElement:   "div",
    validClass:     "input_ok",
    errorClass:     "validation_error",
    rules: {    "address[postcode]":         { required:     true},
                "general[trade]":           { required:     true},
                "address[address_line_1]":   { required:    true},
                "address[address_line_2]":   { required:    true},
                "address[address_line_3]":   { required:    true},
                "general[trade]":           { remote:       true,
                                               required:     true}

          },
     messages: {    trade:                  { remote: "Trade not found."}                               
          }
});

谁能帮帮我?我以前做过,但是使用远程调用从数据库中查找交易的 PHP 脚本。在这种情况下这不是必需的,因为 $tradeString 以自动完成期望的格式返回交易列表。

【问题讨论】:

    标签: jquery validation


    【解决方案1】:

    看起来你需要在这里查看默认示例:http://jqueryui.com/demos/autocomplete/#default

    这段代码看起来不对: 来源:“.$tradeString.”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多