Author Topic: Chars Limit For Comments?  (Read 6236 times)

0 Members and 1 Guest are viewing this topic.

Offline mentally

  • Newbie
  • *
  • Posts: 24
    • View Profile
Chars Limit For Comments?
« on: July 09, 2005, 06:15:52 PM »
hello, i've search the forum but cant seem to find anything on it..

is there a way to limit the chars in a comment?

people post LONG comments with pure emotions which freezes up the whole site. nothing can load until i manually go and delete the comment.

thanks

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Chars Limit For Comments?
« Reply #1 on: July 09, 2005, 08:14:27 PM »
try use javascript in comment_form.html template.

for example: insert into <textarea> tag (not between <textarea> and </textarea> !) this:
Code: [Select]
onkeyup="textrem(this,this.form.rem);"; onkeydown="textrem(this,this.form.rem);"; onkeypress="textrem(this,this.form.rem);"; onblur="textrem(this,this.form.rem);"; onfocus="textrem(this,this.form.rem);"; onchange="textrem(this,this.form.rem);"Then, after </textarea> insert:
Code: [Select]
<br /><input type="text" name="rem" class="commentinput" style="width:30px"; maxlength="3" size="3" value="255" onblur="textrem(this.form.comment_text,this);" readonly /> characters remaining
<script language="javascript">
  var maxlimit = 255
  function textrem( field, rem ) {
    if ( field.value.length > maxlimit )
    {
      field.value = field.value.substring( 0, maxlimit );
      return false;
    }
    else
    {
      rem.value = maxlimit - field.value.length;
    }
  }
</script>
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline live@ct

  • Sr. Member
  • ****
  • Posts: 348
    • View Profile
Re: Chars Limit For Comments?
« Reply #2 on: July 10, 2005, 10:36:20 PM »
a function that cut the # of chars in the latest new comments :?: :?: :?:
Existen 10 tipos de personas, los que entienden el codigo binario y los que no.

Offline mentally

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Chars Limit For Comments?
« Reply #3 on: July 12, 2005, 12:30:55 AM »
thanks a lot

that worked!! lol  :lol:

Offline soyola

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: Chars Limit For Comments?
« Reply #4 on: January 29, 2006, 09:06:37 PM »
Ok what about custom user fields.  How can I limit the characters that users can enter ? For example I have About Me, and Interest fields that I want limit characters

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Chars Limit For Comments?
« Reply #5 on: January 29, 2006, 09:10:42 PM »
What is the problem? its all explained above.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Flo2005

  • Full Member
  • ***
  • Posts: 237
  • Copy & Paste Profi :)
    • View Profile
    • snuup.de! - Bilder - Sounds - Videos - fun4FREE!
Re: Chars Limit For Comments?
« Reply #6 on: February 19, 2006, 04:08:15 PM »
IŽve got a question about this...

Some users write a very long username... e.g. Flo  :mrgreen: so my table will explode :roll:



Now when I set a limit of characters e.g. in field user_name what will happened when a reigistered with a long user name write a comment.

Will it be a problem or is it possible to set this limit... well IŽll try it...

Project offline