Hi greetings of the day here i gave my code and my problem please resolve this,
my problem is:
Here i'm providing a auto list to the user.If the user enter a value like S then the auto list shows all the values starting with S,but user didn't select value from the auto list and n click (with the value of s) insert button then in the table save the value with S.
Here my requirement is if user didn't select any value from the auto list( even a value with S or etc) then get a alert my select any value....when click the insert button.
my code is :
$("#txtCountry").autocomplete({
source: function (request, response) {
var x = $('#txtCountry').val();
$.ajax({
url: "/abc/xyz",
type: "POST",
dataType: "json",
data: { term: x },
success: function (data) {
response($.map(data.countrylist, function (item, r) {
debugger
return {
label: item
}
}));
},
messages: {
noResults: "", results: ""
},
}
},
minLength: 1
})
}
});
});
in insert botton
country = $('#txtCountry').val();//here value is cary but my requirement is user didn't select any value then it should be empty.
if (country == "") {
alert("required");
return false;
}
help me to resolve this.
i'm fighting with this from last 6 hours.