hai ragione sono stato troppo frettoloso, eccoti uno script di esempio:
codice:<html><head><title>test page</title> <script type="text/javascript"> var counter = 0; function enter_textarea(e){ codice_tasto = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode; if (codice_tasto == 13 && !e.shiftKey) { alert('invio!'); e.preventDefault(); } } function length_textarea(textarea){ var max_length = 20; // qui scegli la lunghezza massima if (textarea.value.length > max_length) textarea.value = textarea.value.substr(0, max_length); document.getElementById('count').value = textarea.value.length; } </script> </head> <body> <input type="text" id="count" value="0" /> <textarea onkeypress="enter_textarea(event || window.event)" onkeyup="length_textarea(this)"></textarea> </body> </html>

Rispondi quotando