I follow Limit Textarea Topic, but it doesnt work

angelmorales 08 Jul, 2014
Hello, I follow the intructions in this topic: http://www.chronoengine.com/forums/posts/f5/t21922/limit-text-area.html?hilit=textarea+limit
I use the code posted there:
window.addEvent('load', function() {
  var textarea = $('input_textarea_0');
  // execute the check after each keystroke
  textarea.addEvent('keyup', function() {
    // set the maximum number of characters
    max_chars = 50;
    // get the current value of the input field
    current_value = textarea.value;
    // get current character count
    current_length = current_value.length;
    // calculate remaining chars
    remaining_chars = max_chars - current_length;
    // show the remaining characters
    // Change color if remaining chars are five or less
    if ( remaining_chars <= 5 ) {
      textarea.setStyle('background-color', '#F88');
      textarea.value = textarea.value.substring(0, max_chars-1);
      if ( remaining_chars <= 0 ) {
        remaining_chars = 0;
      }
    } else {
      textarea.setStyle('background-color', 'white');
    }
    $('counter').innerHTML = remaining_chars;
  });
});


But it doesnt work, can you tell me what its wrong?
GreyHead 09 Jul, 2014
1 Likes
Hi angelmorales,

Please move the Load JS action up before the Show HTML action; and check that the </span> tag is complete in the instructions for user - it isn't in your image.

Bob
angelmorales 09 Jul, 2014
I have done your recomendations,I put the Load JS action before the Show HTML action and modify the tag in the instructions for user,

50 chars max <span id='counter'>50</span>

,but it doesnt works, i wish i could attach more images but the REPLY option doesnt allow it, i cant see the option.
Hope you can help me.
Thanks for your quick response.
GreyHead 10 Jul, 2014
Hi angelmorales,

Please post a link to the form so I can take a quick look.

Bob
angelmorales 17 Sep, 2014
Sorry to be late, just to be clear i need to use the JCE editor in the text area so, what i can do?
Thanks
This topic is locked and no more replies can be posted.