Page 1 of 1

Limit Number of Characters in Message

Posted: Fri Apr 01, 2011 4:28 am
by sun28fl
Script URL:
Version of script: 2.2
Hosting company: GoDaddy
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution: limit

Write your message below:

I want to limit the number of characters that customers type in the Message box when submitting a ticket. I tried a solution I found in this forum (topic: "How To Stop People From Breaking Message Limit"), but it seems to have no effect - no error received if I exceed the limit.

In the submit_ticket.php file, I placed the following code below
"$question = hesk_input($_POST['question']);", then made the next IF statement, for "empty($question)", an elseif statement (just in case). What am I doing wrong here?

Code: Select all

if (strlen($question) > 300) 
{ 
hesk_error('Your message is too long, limit it to 300 chars.');
}
Thank you!

Re: Limit Number of Characters in Message

Posted: Fri Apr 01, 2011 3:00 pm
by Klemen
Textarea name is 'message' not 'question'

Re: Limit Number of Characters in Message

Posted: Fri Apr 01, 2011 10:41 pm
by sun28fl
Thanks for that, Klemen!! That was definitely a key piece of info I was missing.

It works! Here's what I did:
Moved my bit of code outside of the 'question_use' IF statement, included the definition of the message variable (using the question section as my guide), and displayed the current character count if user runs over the limit (see code below).

I'm loving the Hesk Helpdesk software! :D
Thank you, Klemen for your quick and helpful reply!

Code: Select all

$message = hesk_input($_POST['message']);
	if (strlen($message) > 300) 
	{ 
		$hesk_error_buffer[]='Please limit your message to 300 characters. You currently have '.strlen($message).' characters in the message';
	}
Regards!