You're listening for the change
event, which will not fire until the input loses focus. Given that the code you've provided does trigger an alert once the focus leaves the input (by tab or click), I'm guessing you were expecting a response after typing but before changing focus. To accomplish that, listen for the input
event instead.