Counts down how many letters input you have left to enter into the textarea box.
Change the value 160 to whatever you like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-1.5.js"></script> <script> function countChar(val) { var len = val.value.length; if (len >= 160) { val.value = val.value.substring(0, 160); } else { $('#charNum').text(160 - len); } }; </script> </head> <body> <textarea id="field" onkeyup="countChar(this)"></textarea> <div id="charNum"></div> </body> </html> |