Topic: character limit for tinyMCE textarea

Hi,

   I am using TinyMCE editor for textarea.how to limit the characters in that textarea.
   500 is limit for that textarea,how to limit characters for this textarea in client side.

   alert message after 500 characters or displaying dynamic count of characters above the text area.

thanks,
Ravi.

Re: character limit for tinyMCE textarea

valdiates_length_of :filed_name, :max => 500

that should work, for the rails end of things. 

However, the harder answer is how to make a dynamically updated character countdown appear in your view.  Like digg or twitter.  E.g., 69/500 characters left. 

Maybe i'm just an Ahole, and google hates me, but there has to be some sort of scriptaculous script/method that people use, shouldn't there be since rails is now at least 3 years old?

i found one with some joker using jquery, but i already use scriptaculous and prototype throughout my project for other stuff.

thoughts?

Last edited by nerb (2009-01-22 11:36:43)

Re: character limit for tinyMCE textarea

looks like my rails brain.com searching came up good.  it got me to observe_field.  Google then got me to this code snippet.

Character countdown using observe_field.

i will test out soon, and hopefully report back on progress tonight.

Re: character limit for tinyMCE textarea

Hi nerb,

I know its been a minute since you posted this but I was hoping you might give me some insight as to your findings.

I am using TinyMCE and want to implement a character count in the same manner you described (digg/twitter) that will show the "live" count as you type into tinymce.

Did you manage to get it working? and would you mind sharing with me how to implement this and if you run into any issues.

I iz Newbie...