Textarea in our forms? Who has never used it? No one !
And the famous question that arrives thereafter « Yes, but when you enter a very long text, we would like the area to expand … it would be much more beautiful! »
To avoid this kind of scene, we have a simple answer to propose to you. It’s a JavaScript library called autosize that allows you to have self-expanding textarea.
This library can be downloaded here: https://github.com/jackmoore/autosize
The easiest way is to download the autosize.js file and drop it on the K2 server, in the K2 smartforms Runtime \ Script directory, create a Common directory and drop the library into it.
The next step, add this tip of javascript in the forms where you want to have the extensible auto controls:
[pastacode lang= »javascript » manual= »%3Cscript%20src%3D%22..%2F..%2F..%2FScript%2FCommon%2Fautosize.js%22%3E%3C%2Fscript%3E%3Cscript%3Eautosize(%24(‘textarea’))%3B%3C%2Fscript%3E » message= »Javascript code » highlight= » » provider= »manual »/]
That’s it, your textarea are now spreading by themselves!
| Before | After |
![]() |
It’s your turn 😉



