Deleting TextField.onChanged

Basically I have a few functions to check to see how many lines of text the user types into a text box.

If the text exceeds 1 line I make the text box red, once they click in the text box again to shorten their input I change it back to white.

So I’m using the following code


    // nick name
    if(temp_pref_name_height > maxHeight){
        _root.main_clip.panel_set.contactPanel.form_pref_name.backgroundColor = 0xFF0000;
        _root.main_clip.panel_set.contactPanel.form_pref_name.onChanged = function(){
            _root.main_clip.panel_set.contactPanel.form_pref_name.backgroundColor = 0xFFFFFF;
            trace("Go back to white");
        }
        trace("2 Lines");
    }else{
        trace("1 Line");
    }

But each time the user type’s a character it recalls what’s inside the onChanged function.

I only want what’s in their to be called once until until the user hit’s submit again. So my question is how can I delete this function or better yet only call it the first time the user clicks in the text box.
I hope I made sense, this seems like such a simple task but I can’t seem to find any solutions.

-thanks