You would need to specify an "onblur" method for the text box. Blur is the opposite of Focus. The text box "gets focus" when tabbed into or clicked on. The text box's onblur event is triggered when the box has focus, then someone tabs out of it or clicks elsewhere.
Hope this helps,
vine type - content management with standards in mind - vinetype.com