News: When asking for support, it helps us and you, if you read the Posting Guidelines

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

December 16, 2019, 03:59:52 AM

Login with username, password and session length

Recent

Members
Stats
  • Total Posts: 189283
  • Total Topics: 20776
  • Online Today: 65
  • Online Ever: 629
  • (November 08, 2018, 01:36:54 PM)
Users Online
Users: 0
Guests: 45
Total: 45

Author Topic: Character countdown for the shoutbox.  (Read 7625 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. :)