homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

server-side maximum character limit for textarea?

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

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)

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)

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)

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].

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved