Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

server-side maximum character limit for textarea?



5:01 pm on Apr 4, 2008 (gmt 0)

5+ Year Member

Hello everyone, I found a few methods but this stuff is still somewhat greek to me, so which do you guys prefer? Thanks!



$position=14; // Define how many character you want to display.
$message="You are now joining over 2000 current";
$post = substr($message, 0, $position);
echo $post;
echo "...";


$charLimit = 500;
if (strlen($_POST['desc']) <= $charLimit)
// do something
} else {
// do error


if (strlen($_POST['input']) > 300) {
// appropriate rejecting mechanism
} else {
// do what you want with it.


5:16 pm on Apr 4, 2008 (gmt 0)

5+ Year Member

Better to tell us what is the issue that you want to solve with this methods. the first, second, third & forth are good , every one for specific needs.


6:02 pm on Apr 4, 2008 (gmt 0)

5+ Year Member

Hello, I want to set a maximum amount of characters in my textarea on the server side. I already have this set on the client side. So I am just looking for the best method to add to my pre-existing formmail.php. Thanks!


6:25 pm on Apr 5, 2008 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

It depends on whether or not you want to clip the text at the last character in the middle of a word or not. If you don't care, then using substr [php.net] will be fine. If you want to make sure you don't clip a word you could use wordwrap [php.net].

Featured Threads

Hot Threads This Week

Hot Threads This Month