Autor | Zpráva | ||
---|---|---|---|
Hugoman Profil |
#1 · Zasláno: 25. 3. 2007, 11:18:28
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 |
#2 · Zasláno: 25. 3. 2007, 11:32:44
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 |
#3 · Zasláno: 25. 3. 2007, 11:34:04
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 * |
#4 · Zasláno: 26. 3. 2007, 10:02:36
Tu mas presny priklad: www.kasman.sk/index.php?id_clanku=1148
|
||
Časová prodleva: 19 let
|
Toto téma je uzamčeno. Odpověď nelze zaslat.
0