Código HTML:
<html> <head> <script language="JavaScript"> function caritas(Which){ document.form.comentario.value = document.form.comentario.value + Which; } function contador (campo, cuentacampo, limite) { if (campo.value.length > limite) campo.value = campo.value.substring(0, limite); else cuentacampo.value = limite - campo.value.length; } </script> </head> <body> <form name="form"> <!-- Textarea --> <textarea name="comentario" onKeyDown="contador(this.form.comentario,this.form.remLen,2000);" onKeyUp="contador(this.form.comentario,this.form.remLen,2000);"> </textarea> <!-- Smiley --> <a href="javascript:caritas('smiley1')"> <img src=../smileys/smiley1.gif> </a> <!-- Contador --> <p>Caracteres restantes: <input type="text" name="remLen" value="2000" readonly> </p> <input type="submit"> </form> </body> </html>