You can use the Enter event which executes when the cursor is in the field, hence has focus. You can also use the Exit event when the field is exited > lost focus
and if you use "event propagation" you could have a script in the top elements enter event, which will be fired whenever any form object triggers a enter event.