how can i use validate string before showing suggestion. And if string contain invalid string then it will show an error message like:
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
}
});
});