If you are using HTML 5, you need to specify that in your DOCTYPE declaration.
For a valid HTML 5 document, it should start with:
Before HTML 5, the textarea element did not have a maxlength
attribute.
You can see this in the DTD/spec:
In order to limit the number of characters typed into a textarea
, you will need to use javascript with the onChange
event. You can then count the number of characters and disallow further typing.
Here is an in-depth discussion on text input and how to use server and client side scripting to limit the size.
Here is another sample.