This is a full sample:
<html>
<head>
<script type="text/javascript"></script>
</head>
<body">
<textarea id="tarea" onkeypress="counter(event, 150);"></textarea>
<div id="output" />
</body>
</html>
This solution shows how to output value, and how to prevent entering more characters if the limit it exceeded. However, backspace is allowed (and delete is never blocked).
—SA