GEMCC
asked on
Is there a textarea character limit in PHP
Hello,
I have created a form in PHP that includes a textarea. The form information is being sent via e-mail. Is there a character limit in textarea?
I am using PHP with Pear on a Linux server.
Please advise.
Have a great day,
Don
I have created a form in PHP that includes a textarea. The form information is being sent via e-mail. Is there a character limit in textarea?
I am using PHP with Pear on a Linux server.
Please advise.
Have a great day,
Don
In Php you can only truncate the textarea value after the user has submitted it to the server script. But this is not a great idea, because it lets the user believe to have sent a long text whereas a part of it is deleted on the server side.
It's better to ue javascript to set the limit of chars a user can type within the textarea. Give to your text area an id (for instance, <textarea id='mymesage'>) and then use JQuery:
It's better to ue javascript to set the limit of chars a user can type within the textarea. Give to your text area an id (for instance, <textarea id='mymesage'>) and then use JQuery:
$('#mymessage').on('keypress', function(){
var limit = 255;
if($(this).val().length > limit){
$(this).val($(this).val().substr(0, limit));
}
});
No, you would normally use JavaScript to check that the users were not entering more characters than you want them to.
Lol. Unless gr8gonzo knew something I ignore, this is a perfect example of how we can interpret in two opposite ways the same question if the asker isn't precise and descriptive enough!
@Marco - true, although I would suggest that he use the maxlength attribute over Javascript if he wants to enforce a limit. I would also recommend truncating the data on the server-side, as well (just in case a malicious user posts data directly instead of using the form).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Never mind. I found the issue. The script I was using cut the message off.
Thanks for your responses.
Have a great day,
Don
Thanks for your responses.
Have a great day,
Don
ASKER
Answered my question.
:-) Thanks for the points and thanks for using EE, ~Ray
If it's basic form data, you shouldn't need to really worry about limits. If anything, you may want to add the maxlength attribute to the tag and specify your own limit so that someone doesn't put in 10 megabytes of text that then gets emailed to you and sucks up your bandwidth.