Scrollbar Visiblilty toggle

I saw this on a forum once but forgot to note it down. How can you set the visibilty of a scrollbar to true only if the text extends below the height of the text field. Other wise if the text does not extend below the height of the scroll field the visibilty is false.