Javascript in text field with autocomplete

If I am using the autocomplete plugin, and I have a text field
specified in a form that incorporates autocomplete, such as:

<%=
text_field_with_auto_complete :doctor, :organization, :autocomplete =>
"off" %>

how can I put javascript event handlers to if (e.g. keypress,
onchange, etc.) ? WHat I really want to do is call a method in my
controller if either:
1. The text field is empty, and previously was not -or-
2. The text field is now not empty, and previously was empty.

Thanks, RVince