var SEARCH_KEY = "";
---------------------------------------------------
application.importType("wcp.library.util.AutoSuggest");
application.importType("wcp.library.util.DataProvider");
application.addType(txtClientName, "wcp.library.util.AutoSuggest");
//Add required Autosuggest classes to the inputs
application.inherit(ClientsProvider, DataProvider)
txtClientName.registerDataProvider(new ClientsProvider());
-----------------------------------------------------------------
function ClientsProvider() {}
ClientsProvider.prototype.getSuggestions = function () {
var suggestions = null;
//read the current input vlaue if string length is less than 3 clear
var strValue = txtClientName.getValue();
if (strValue.length > 2 && SEARCH_KEY != strValue) {
//debugger;
// dont fire webservice again.. display the existing names' list if oldKey is the substr of newKey
if (strValue.toLowerCase().indexOf(SEARCH_KEY.toLowerCase()) != -1 && SEARCH_KEY != "") return NAME_LIST;
//empty the current name list and fill the new one
SEARCH_KEY = strValue;
suggestions = updateClientNameSuggestions(strValue);
NAME_LIST = suggestions;
}
return suggestions;
}
--------------------------------------
function Form_BeforeClose(eventObject) {
SEARCH_KEY = "";
}