direi che potresti sfruttare l'evento lostfocus