我遇到了问题。我有两个输入字段,通过easy-autocomplete js显示下拉项。它运作良好。我想在字段为空或编辑时禁用提交按钮。我的代码无法正常工作。如何解决?
var aTags = ["ask", "always", "all", "alright", "one", "foo", "blackberry", "tweet", "force9", "westerners", "sport"];
var bTags = ["aaaaaaa", "bbbbbbbb", "ccccccc", "ddddddddd"];
var options1 = {
//data: ["blue", "green", "pink", "red", "yellow"]
data: aTags.concat(bTags),
list: {
onMouseOutEvent: function() {
//alert("Click !");
$("button").removeAttr("disabled");
},
onSelectItemEvent: function() {
var value = $("#basics").getSelectedItemData();
$("#index-holder").val(value).trigger("change");
$("#basics").val(value).trigger("change");
$("#basics").on("change paste keyup", function() {
// $("button").attr("disabled", "disabled");
});
},
match: {
enabled: true
},
}
};
$("#basics").easyAutocomplete(options1);
var options2 = {
//data: ["blue", "green", "pink", "red", "yellow"]
data: aTags.concat(bTags),
list: {
onMouseOutEvent: function() {
//alert("Click !");
$("button").removeAttr("disabled");
},
onSelectItemEvent: function() {
var value = $("#basics2").getSelectedItemData();
$("#index-holder").val(value).trigger("change");
$("#basics2").val(value).trigger("change");
$("#basics2").on("change paste keyup", function() {
$("button").attr("disabled", "disabled");
});
},
match: {
enabled: true
},
}
};
$("#basics2").easyAutocomplete(options2);
$("button").attr("disabled", "disabled");