I want to force the user to select from the auto-complete options.
NB: I do not want to use a drop down menu.
Try using this
var isItemSelected = false;
//Handler for AutoCompleter OnClientItemSelected event
function onItemSelected() {
isItemSelected = true;
}
//Handler for textbox blur event
function checkItemSelected(myTextBox) {
if (!isItemSelected) {
alert("Please select item from the list only!");
myTextBox.focus();
}
else {
//reset isItemSelected
isItemSelected = false;
}
}
And then throw this in the Textbox:
onblur="checkItemSelected(this)"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.