That greatly depends on how you are "displaying it as text" in the first place. You have given us no information on how this text is handled once it is input by the user, so how can we help without that information?
I am displaying the data through java script-lets and some jQuery plugins like flexigrid etc use the data as json objects. So I return that data as json too.
By length, I meant that I had to do this on each and every input field in my application. I am actually inquiring if there is some kind of form attribute or a js function which could do it for me generically, then that would have been great, otherwise I will have to follow your solution.