Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how can i use validate string before showing suggestion. And if string contain invalid string then it will show an error message like:
C#
No result found, please check your spelling and try again.


What I have tried:

I am using jquery autosuggestion. My code is:
$(".autosuggest").each(function(){

$(this).autocomplete({

source: function(request, response) {
$.ajax({
url: "autocomp3.asp",
dataType: "json",
data: {
term : request.term,
param : paramName,
con : con,
ver : lang
//country_id : $("#country_id").val()
},
success: function(data) {

$.each(data, function(i) {
//outputdata[i] = data[i].value;
outputdata = data;
//alert (data[i]);
});
if (data == "")
{
$("#loc").html("No result found, please check your spelling and try again.");
$("#disBtn").css("display", "none");
}else{
$("#disBtn").css("display", "block");
$("#loc").html("");
}
response(data);
}
});
},
search: function () {
$(this).addClass('loadinggif');
$("#"+hiddenIdField+"").val("");
},
response: function (event, ui) {

$(this).removeClass('loadinggif');
len = ui.content.length;
//alert(ui.item.value);
},
minLength: 1,
delay: 300,
select: function (event, ui) {

//$("#txtAllowSearch").val(ui.item.label); // display the selected text
$("#"+hiddenIdField+"").val(ui.item.id); // save selected id to hidden input
}
});
});
Posted
Updated 1-Sep-16 2:09am

1 solution

Look at the supported events in the documentation (especially "search")

Autocomplete Widget | jQuery UI API Documentation[^]

If you need help implementing one google and you'll find source code.
 
Share this answer
 
v2

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