Examples - Text Area - MaxLength Attribute

This is a very simple example of how to use the maxlength attribute inside a textarea to prevent the user from typing more text into the field than they should be allowed to.
   
Comments:
Code for the TextArea above:
<textarea id="txtComments"
maxlength="30"
style="width:99%;height: 80px;"></textarea>
Notes:
Whilst the maxlength attribute applied here prevents the user inputting more than 30 characters of text, it is still possible to paste more than this into the textarea. However, the maxlength value takes affect when the onchange event of the textarea fires i.e. the user moves focus to another control. When this event fires the text entered is cut to contain no more than the maximum number of characters specified by the maxlength attribute.