News: February 16th, 2020, The Tinyportal team is pleased to announce the release of ~~ TinyPortal 1.6.5! GET IT NOW!!!

Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media
Welcome, Guest. Please login or register.
Did you miss your activation email?

April 06, 2020, 04:05:20 PM

Login with username, password and session length

Recent

Members
Stats
  • Total Posts: 189583
  • Total Topics: 20808
  • Online Today: 71
  • Online Ever: 917
  • (January 21, 2020, 09:02:26 AM)
Users Online
Users: 2
Guests: 34
Total: 36

Author Topic: Character countdown for the shoutbox.  (Read 8398 times)

0 Members and 1 Guest are viewing this topic.

Offline WillyP

  • Support Team
  • *
  • Posts: 769
    • Planet Descent
Re: Character countdown for the shoutbox.
« Reply #10 on: January 12, 2014, 06:39:28 PM »
Replaced with a whole new script. In the head:
Code: [Select]
<script language="javascript" type="text/javascript">
function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
} else {
limitCount.value = limitNum - limitField.value.length;
}
}
</script>

In the shout template textarea:
Code: [Select]
onKeyDown="limitText(this.form.limitedtextarea,this.form.countdown,250);"
onKeyUp="limitText(this.form.'. $context['tp_shout_post_box_name']. ',this.form.countdown,250);"

And below the textarea:
Code: [Select]
<input readonly type="text" name="countdown" size="3" value="250"> characters left<br />
This code lifted from: How to Limit the Number of Characters in a Textarea or Text Field

Offline IchBin™

  • Developer
  • *
  • Posts: 16228
    • My Website
Re: Character countdown for the shoutbox.
« Reply #11 on: January 13, 2014, 08:15:34 AM »
Good work WillyP! Yeah I've often thought about these things. Useful to have, and not a big problem to implement as you noticed. :)