I just realized that this piece of code works well in Firefox but not in IE 8. I need to automatically populate the list when the user enters at least 8 characters in the input field.
$('#inputField').keyup(function (event) {
var $inputField = $(this);
if ($inputField.val().length >= 8) { popularListBox(); }
});
function populateListBox(){
$.get("Default.aspx?name=test", function(data) {
$('#listBox').children().remove();
var options = data;
$("#listBox").html(data);
});
}
You want to detect the change in input field and then do some actions, right?
I think you may detect the changes instead of keyboard actions only. For example, how about if the user paste from clipboard?
Please try these codes:
It works for most input field including textarea. Please check jQuery site for more information.
In my experience, .keyup() and .keypress() often get errors in IE. I would like to use .keydown() if possible (case by case)