Limiting the length of characters in a textarea using javascript

I use a javascript that‘s very easy to use. All you need to do is include the JS file and add a maxlength attribute to a textarea element with the amount of characters you want to allow. That‘s it. I use this to limit the input of characters for page meta-tags to 160 characters.
e.g.
< textarea cols="60" name="field" rows="3" maxlength="160">
And add onload=‘setMaxLength()’ to the body tag:
< body onload="setMaxLength()">