FULL STACK   ·   UI   ·   UX   ·   GRAPHICS   ·   DEVELOPER   ·   INSTRUCTOR

Adam Khoury

Donate funds to show love and support

Click the button below to donate funds securely online. You can use your PayPal account or a credit card.

Your donations help free up my time to produce more content and assist in covering server costs. It's also a great way to say thanks for the content!

Application Configuration

Adam will be adding options here soon.

textarea Form Field Character Counting and Limiting

Published :
Author :
Adam Khoury
Learn to use JavaScript to limit and count a text field in your HTML based forms. Show the user how many characters are remaining that they can type into that field. It will limit the amount they can type in real time also. <html> <head> <script> var maxAmount = 250; function textCounter(textField, showCountField) { if (textField.value.length > maxAmount) { textField.value = textField.value.substring(0, maxAmount); } else { showCountField.value = maxAmount - textField.value.length; } } </script> </head> <body> <form> <textarea name="ta" rows="6" style="width:340px;" onKeyDown="textCounter(this.form.ta,this.form.countDisplay);" onKeyUp="textCounter(this.form.ta,this.form.countDisplay);"></textarea> <br> <input readonly type="text" name="countDisplay" size="3" maxlength="3" value="250"> Characters Remaining </form> </body> </html>