[jQuery] [autocomplete] how to clear hidden "key" field when user changes text value?

[jQuery] [autocomplete] how to clear hidden "key" field when user changes text value?


Hi all,
I'm using autocomplete plugin, when the user types something the
backend responds value and key information (for instance:
John|76178
Mike|87252
Peter|87511
Using .result I'm setting the key in a hidden field in my form.
$('#autocompleteTextboxId').result(function(event, data, formatted) {
    if (data)
        $('#autocompleteHiddenValueId').val(data[1]);
});
But what if the user changes his mind and after choosing "John" types
something else in the textbox (without actually chosing a new option
from the autocomplete options) or even deletes the whole text? As
things are now, the data previously set in the hidden field remains
there. So the user might post the form thinking that his selection is
blank, but the system actually thinks that he selected "76178".
Is there a way to "clear" the hidden field when the user types
something?
I tried by setting some action to "focus" so that whenever the user
focuses on the textbox the hidden value is cleared but it seems that
after the user chooses a value in the autocomplete options, the plugin
sets focus to the text field (hence making this action execute, thus
clearing the hidden value everytime).
$('#autocompleteTextboxId').focus(function() {
    $('#autocompleteHiddenValueId').val('');
});
It would be cool if we had something like ".textChanged" (similar to
".result" above) where we can do some action when the user changes the
text on the field.
Maybe some of the JS wizards here can suggest something.
Thanks.