Jump to content


[Hack] Limit Characters in Shoutbox post


  • You cannot reply to this topic
No replies to this topic

#1 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 01 June 2006 - 10:48 PM

This hack will limit the number of characters that can be used in a shoutbox post. In this example the post is limited to 80 characters.

RUN this database query:
ALTER TABLE `mkp_urlobox` CHANGE `message` `message` VARCHAR( 80 ) NOT NULL
FIND in /mkportal/modules/urlobox/index.php

		<textarea cols="10" style="width:75%" rows="12" name="ta"></textarea>
REPLACE WITH:
		  <textarea cols="10" style="width:75%" rows="12" name="ta" onKeyDown="limitText(this.form.ta,this.form.countdown,80);" onKeyUp="limitText(this.form.ta,this.form.countdown,80);"></textarea>
		

		<div style="font-size: 10px;">(Maximum characters: 80)

You have <input readonly type="text" name="countdown" size="3" value="80"> characters left.</div>
FIND in /mkportal/templates/*/mkp.js:
//-->
ADD ABOVE:
// Limit Number of Characters in Textarea
// From http://www.mediacollege.com/internet/javascript/form/limit-characters.html
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}



Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users