»
EnglishFrenchVietnamese

Print - Limit Textarea script - JavaScriptBank.com

Full version: jsB@nk » Utility » Counter-Limitation » Limit Textarea script
URL: https://www.javascriptbank.com/limit-textarea-script.html

Limit Textarea script © JavaScriptBank.comThis JavaScript controls a maximum textarea input amount and updates a small counter with how many characters are left with each keystroke. Dynamic fix now allows you to use this JavaScript in multiple textboxes on a page. Easy!

Full version: jsB@nk » Utility » Counter-Limitation » Limit Textarea script
URL: https://www.javascriptbank.com/limit-textarea-script.html



JavaScript
<SCRIPT language=JavaScript><!--function doleft2() {document.form.text.value = "";}function docheck() {char = eval(document.form.text.value.length)var dif = eval(char - 125)var value = document.form.text.value.substr(0,char-dif);document.form.text.value = value;var left = "0"}function doleft() {total = eval("125")char = eval(document.form.text.value.length)left = eval(total - char)if (left <= "-1"){var dif = eval(char - 125)var value = document.form.text.value.substr(0,char-dif);document.form.text.value = value;var left = "0"}document.form.left.value = left}document.write("<body OnLoad=\"doleft2()\">")--></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<FORM name=form onsubmit="docheck();alert('This javascript will not send.  It is just a sample.')"><TEXTAREA id=text onkeyup=javascript:doleft(); onclick=docheck() name=text rows=6 cols=24></TEXTAREA></TEXTAREA><BR><BR>You have <INPUT id=left readOnly size=3 value=125 name=left></INPUT> characters left.<BR><BR><INPUT type=submit value=Send! name=""></INPUT>&nbsp;&nbsp; <INPUT type=reset value=Clear><BR><BR></FORM><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->