Current version: 1.0
Compatible with: M1.0 - C1.2 rc2
Author: visiblesoul
Download: N/A
Demo: N/A
Description:
How to limit characters and display an update of characters remaining in Shoutbox using javascript
Tested with FF2 and IE7.
FIND in mkportal/modules/urlobox/index.php:
<textarea cols="10" style="width:75%" rows="12" name="ta"></textarea>REPLACE WITH:
";
//Limit characters
$charlim = 50; //How many characters to allow
$output .= "
<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>
<textarea cols="10" style="width:75%" rows="12" name="ta" onkeydown="limitText(this.form.ta,this.form.countdown,$charlim);" onkeyup="limitText(this.form.ta,this.form.countdown,$charlim);"></textarea>
<div>(Maximum characters: $charlim) You have <input readonly="readonly" type="text" name="countdown" size="3" value="$charlim" /> characters left.</div>
Set your character limit by replacing "50" on this line with your desired limit...$charlim = 50;Keep in mind that the real limit is set in the database and not in the javascript. It is possible to bypass the javascript limit.
The default datatype for the mkp_urlobox "message" field is "TEXT.This allows very long messages. To impose a much lower limit in the database such as 50 characters run this query...
BACKUP YOUR DATABASE FIRST! No Warranty.
ALTER TABLE `mkp_urlobox` CHANGE `message` `message` VARCHAR( 50 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL
Quote
Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3 and later versions. The effective maximum length of a VARCHAR in MySQL 5.0.3 and later is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used.
from: http://dev.mysql.com....0/en/char.html
from: http://dev.mysql.com....0/en/char.html
http://dev.mysql.com...ring-types.html
http://dev.mysql.com/doc/refman/5.0/en/sto...quirements.html













