I want a limit on a message (let's say 250 char.) in CGI (yes, I know how do it with the <input> tag but you can Download that page and changes the settings and the post a non char. limited message)
How can I do this?Make sure to set the limit in the input tag, maybe something like this (PERL):
if ($comments =~ m/.{251,}/) {&Dowhatever;}
change $comments to match your form/script and create a subroutine (&Dowhatever) to handle the error.
Give it a try and see if it works.
KevinI ment someting like this (this is the PHP like version... i'm not so into CGI...)
$message=substr($message,0,255);
$lastspacepos=strrpos($message,' ');
return substr($message,0,$lastspacepos);
which crops the massage to 255 characters
then skip back to the last space from the 255 characters (so u wont get half words at the end)
(maybe I take a try to port this cgi-script to php) But this one is for a pal of mine...Sorry, my PHP skills are zip-zero-nada.
Kevinwhat I mend was grap the massage crop the message to the first 255 character then skip back to the last white space. (So the last word isn't a half word).
what you gave was"
if the message is bigger then 255 char. then the do the error part handeling.
How? I'm not very familiar with CGI/Perl![Smile :) :)](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f642.png)
(The previous message shows a smimilar something in PHp format... it might help you with something)
How can I do this?Make sure to set the limit in the input tag, maybe something like this (PERL):
if ($comments =~ m/.{251,}/) {&Dowhatever;}
change $comments to match your form/script and create a subroutine (&Dowhatever) to handle the error.
Give it a try and see if it works.
KevinI ment someting like this (this is the PHP like version... i'm not so into CGI...)
$message=substr($message,0,255);
$lastspacepos=strrpos($message,' ');
return substr($message,0,$lastspacepos);
which crops the massage to 255 characters
then skip back to the last space from the 255 characters (so u wont get half words at the end)
(maybe I take a try to port this cgi-script to php) But this one is for a pal of mine...Sorry, my PHP skills are zip-zero-nada.
Kevinwhat I mend was grap the massage crop the message to the first 255 character then skip back to the last white space. (So the last word isn't a half word).
what you gave was"
if the message is bigger then 255 char. then the do the error part handeling.
How? I'm not very familiar with CGI/Perl
![Smile :) :)](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f642.png)
(The previous message shows a smimilar something in PHp format... it might help you with something)