autocomplete+focusout issue
in Using jQuery
•
11 years ago
I am using auto-complete as well as focus-out events in a text box. focusout event is used to save the entered data in the text box if the data not present in the auto-complete list.
please refer my code:
'auto-complete
$(".textBankName").each(function () {
var temp = $(this).attr('id'); temp = temp.substring(temp.length - 1, temp.length);
var GCId = 44;
$(this).autocomplete('../Handler/ajaxPopulatePsoName.ashx?Id=' + GCId, { idHolder: "RightContentPlaceHolder_gvdATM_hdnBankName_" + temp }});
});
'focusout:
$(".textBankName").live('focusout', function (event) {
if ($.trim($(this).val()) != "") {
$("#RightContentPlaceHolder_lblMessage").text();
if ($(this).parent().find("input:hidden").val() == "") {
if (confirm("Do you want to add new bank: " + $(this).val())) {
var bName = $(this).val(); $.get('../Handler/ajaxAddBank.ashx?q=' + bName, function () { });
var idtoget = $(this).attr('id'); $("#" + idtoget).focus(1, function () {
$(this).parent().parent().find('.atmName').focus();
});
} else {
$(this).val(""); $("#RightContentPlaceHolder_lblMessage").text('Bank name is mandatory'); var idtoget = $(this).attr('id'); $("#" + idtoget).focus(1, function () {
$(this).focus();
});
}
}
}
using keyboard . the focus-out event will work perfectly..without any error
but while using mouse for selection... unnecessarily invoking confirm box with message""Do you want to add new bank"" without checking whether the data is available in the autocomplete list or not.
please let me know the possible solution for this issue.
thanking you all
Mebin Thomas
1