Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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 :
JavaScript
$("#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.
JavaScript
if (country == "") {
alert("required");
return false;
}

help me to resolve this.

i'm fighting with this from last 6 hours.
Posted
Updated 23-Sep-15 2:47am
v2
Comments
aarif moh shaikh 23-Sep-15 8:35am    
not Clarify Question..
RamAchanta 23-Sep-15 8:46am    
Hide Copy Code
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 click (with the value of S) insert button then the table save with the value of 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 when click the insert button.
Member 12003400 24-Sep-15 1:21am    
Stop putting same questing again and again only with changing header.
RamAchanta 25-Sep-15 8:54am    
thanks for your suggestion...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900