Autor Zpráva
Hugoman
Profil
Kontrola poctu znakov v <textarea> za chodu za pomoci JS, jak urobit aby mi dole ukazovalo kolko mi este ostava znakov do maximalnej velkosti pola? Neviem to vygooglit.
souki
Profil
Přiřadíš mu ID a pak přes onkeydown (http://www.jakpsatweb.cz/javascript/udalosti.html#klavesnice) kontroluješ délku (http://www.jakpsatweb.cz/javascript/objekt-string.html#length)
Hugoman
Profil
dik souki,

este nieco, nasiel som presne to, co som hladal, vyzera to takto ;)

<SCRIPT LANGUAGE="JavaScript">// function parameters are: field - the string field, count - the field for remaining characters number and max - the maximum number of characters
function CountLeft(field, count, max) {
// if the length of the string in the input field is greater than the max value, trim it
if (field.value.length > max) field.value = field.value.substring(0, max); else
// calculate the remaining characters
count.value = max - field.value.length; } </script>

/////////////////////// HTML ///////////////////////////

<center> <form name=sample action=""> <font size="1" face="arial, helvetica, sans-serif"> Only 50 characters allowed! // at every key up and key down event the upper function is called <input name="text" type="text" size="40" onKeyDown="CountLeft(this.form.text,this.form.left,50);" onKeyUp="CountLeft(this.form.text,this.form.left,50);"> <input readonly type="text" name="left" size=3 maxlength=3 value="50"> characters left</font> </form> </center>
kekso
Profil *
Tu mas presny priklad: www.kasman.sk/index.php?id_clanku=1148
Toto téma je uzamčeno. Odpověď nelze zaslat.