Version compl�te: jsB@nk » Utilitaire » Compteur-Limite » De caractères/mots
URL: https://www.javascriptbank.com/character-word-count.html
Calculer et afficher le nombre de caractères dans un TEXTAREA avec cette JavaScript. Utiles, par exemple, pour aider vos visiteurs manuellement garder leur longueur d'entrée en échec.
Version compl�te: jsB@nk » Utilitaire » Compteur-Limite » De caractères/mots
URL: https://www.javascriptbank.com/character-word-count.html
<script language="JavaScript"><!-- Begin var submitcount=0; function checkSubmit() { if (submitcount == 0) { submitcount++; document.Surv.submit(); } }function wordCounter(field, countfield, maxlimit) {wordcounter=0;for (x=0;x<field.value.length;x++) { if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ") {wordcounter++} // Counts the spaces while ignoring double spaces, usually one in between each word. if (wordcounter > 250) {field.value = field.value.substring(0, x);} else {countfield.value = maxlimit - wordcounter;} } }function textCounter(field, countfield, maxlimit) { if (field.value.length > maxlimit) {field.value = field.value.substring(0, maxlimit);} else {countfield.value = maxlimit - field.value.length;} }// End --></script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<form name="Surv"><table border="0" cellspacing="0" cellpadding="3" width="550"><tbody><tr><td valign="top"><font color="#000000" size="2" face="verdana, helvetica, arial">In 100 <b>words</b> or less, why do you (or would you) like living on the coast?</font><font color="#ff0000" size="2" face="verdana, helvetica, arial">*</font></td><td valign="top"><textarea name="Q3367" cols="40" rows="5" wrap="hard" onkeydown="wordCounter(this.form.Q3367,this.form.remLen,100);" onkeyup="wordCounter(this.form.Q3367,this.form.remLen,100);"></textarea><br>Words remaining: <input type="box" readonly="readonly" name="remLen" size="3" value="100"></td></tr><tr><td colspan="2"><hr width="80%"></td></tr><tr><td valign="top"><font color="#000000" size="2" face="verdana, helvetica, arial">In 100 <b>characters</b> or less, why do you (or would you) like living on the coast?</font><font color="#ff0000" size="2" face="verdana, helvetica, arial">*</font></td><td valign="top"><textarea name="Q336" cols="40" rows="5" wrap="hard" onkeydown="textCounter(this.form.Q336,this.form.remLentext,100);" onkeyup="textCounter(this.form.Q336,this.form.remLentext,100);"></textarea><br>Characters remaining: <input type="box" readonly="readonly" name="remLentext" size="3" value="100"></td></tr></tbody></table><input type="button" value="Submit" onclick="" name="submit1"><input type="reset" value="Reset" id="reset1" name="reset1"></form><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->