How to use maxlength on textarea in struts 1 html tag

Victor picture Victor · Jun 19, 2013 · Viewed 10.2k times · Source

In struts 1 tags for html:textarea here

I do not see a maxlength attribute. How can i restrict the user from entering more than 100 characters? Also why did struts 1 omit such a basic attribute?

Answer

Mariusz Lipiński picture Mariusz Lipiński · Nov 7, 2013

Add the attribute using JS.

Put something like this after your textarea:

<script type="text/javascript">
    document.getElementById('textarea-id').setAttribute('maxlength', '512');
</script>