Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-10-20 16:33:40

trailgirl
Member
Registered: 2004-06-04
Posts: 68
Website

Limit Length of Comments?

Is there a way to limit the number of characters that a visitor can enter into the message field?

Offline

#2 2005-10-21 22:32:47

jaredigital
Member
From: Texas
Registered: 2004-10-26
Posts: 26
Website

Re: Limit Length of Comments?

I believe so. You’ll need to hack your comments.php file, though.

Open it up and find this line (around Line 121):

$textarea = '<textarea class="txpCommentInputMessage" name="message"'.$msgcols.$msgrows.$msgstyle.' tabindex="4">'.htmlspecialchars($message).'</textarea>';

Change it to this:

$textarea = '<textarea class="txpCommentInputMessage" name="message"'.$msgcols.$msgrows.$msgstyle.' tabindex="4" maxlength="xxx">'.htmlspecialchars($message).'</textarea>';

Adding the maxlength="xxx" attribute should limit the number of characters that can be entered into the field. Of course, change xxx to the number of characters you wish to limit the field to.

Last edited by jaredigital (2005-10-21 22:38:08)

Offline

#3 2005-10-22 07:42:03

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: Limit Length of Comments?

There is no maxlength for textarea. You have to use either Javascript (which will only work if users have Javascript enabled – ;)), or you have to (have someone) write a plugin that intercepts the comment and does the necessary things (like changing submit to preview, and adding a message etc.).

Offline

Board footer

Powered by FluxBB