Hello guys! I've a problem, i wrote this script today, it controls the max lenght of chars of textarea and input text, but also if it advise me of the var of controls of chars is bigger of counter the script continue i must exit from function, but i don't know how... can you help me? thanks! this is the script.. <script language="JavaScript"> function conta(){ var chars = document.post.commento.value.length; if (chars > 255 ) { window.alert("Errore! Hai superato il limite di caratteri nel commento!"); // NOW EXIT } } function count(){ var chars = document.post.titolo.value.length; if (chars > 50 ) { window.alert("Errore! Hai superato il limite di caratteri nel titolo!"); // NOW EXIT } } </script> Code (markup):
Buona notte: Use "return false". <script language="JavaScript"> function conta(){ var chars = document.post.commento.value.length; if (chars > 255 ) { window.alert("Errore! Hai superato il limite di caratteri nel commento!"); // NOW EXIT return false; } } function count(){ var chars = document.post.titolo.value.length; if (chars > 50 ) { window.alert("Errore! Hai superato il limite di caratteri nel titolo!"); // NOW EXIT return false; } } </script> Code (markup):
Don't use "post" for the form name. Use a different name. Try this, otherwise, post the html for the form and explain exactly what you are trying to do. <script type="text/javascript"> function conta(){ var chars = document.forms[0].commento.value.length; if (chars > 255 ) { alert("Errore! Hai superato il limite di caratteri nel commento!"); return false; } alert('Conta va bene'); return true; } function count(){ var chars = document.forms[0].titolo.value.length; if (chars > 50 ) { alert("Errore! Hai superato il limite di caratteri nel titolo!"); return false; } alert('Conta va bene'); return true; } </script> Code (markup):
thanks Mike H. I worked out with maxlenght's html tag and strlen's php function... but in this forum there is english man or italian?? forza italia
Di niente, prego. Sono studiano Italiano, il mio giovane amico. Hanno un bel giorno. Dio sorride su lei.