I think the item you're looking for is the JavaScript event handler called onBlur().
With a form field which has the onBlur() function, as soon as the focus is removed from the field (the user clicks outside of the field or hits tab), a JavaScript function can be run.
Look for onBlur in a search engine or a JavaScript web site.
-Rich