Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9057015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:20:44+00:00 2026-06-16T14:20:44+00:00

Basically I use TinyMCE for my text areas for easier editing and someone constructed

  • 0

Basically I use TinyMCE for my text areas for easier editing and someone constructed this JS for me to make a textarea only go to 255 characters.

The only problem is that it affects all textareas on a page its included on instead of a set one, I know no JS so I am wandering if one of you wizards could guide me to add a place I can set what textarea to affect?

<script type="text/javascript" src="/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
        mode : "textareas",
        theme : "advanced",
        plugins : "bbcode",
        theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,styleselect,removeformat,cleanup,code",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "bottom",
        theme_advanced_toolbar_align : "center",
        theme_advanced_styles : "Code=codeStyle;Quote=quoteStyle",
    theme_advanced_resizing : true,
    theme_advanced_path : false,
        content_css : "css/bbcode.css",
        entity_encoding : "raw",
        add_unload_trigger : false,
        remove_linebreaks : false,
        inline_styles : false,
        forced_root_block : '',
        convert_fonts_to_spans : false,
        theme_advanced_statusbar_location : "bottom",
    setup: function(ed) {
        ed.onKeyUp.add(function(ed, e) {
        // What is the max amount of characters you want
        var maxChars = 255;
        var content = tinyMCE.activeEditor.getContent();
        // Remove any BBCode tags from the count
        var strip = content.replace(/\[\/?(?:b|i|u|url|quote|code|img|color|size)*?.*?\]/img, '');
        // Set the text for what we want to display in the status bar
        var text = strip.split(' ').length + " Words, " + strip.length + " Characters"
        // Show the status bar message
                tinymce.DOM.setHTML(tinymce.DOM.get(tinyMCE.activeEditor.id + '_path_row'), text);
        // Is there more Characters than we want
        if (strip.length > maxChars) 
        {
            // Show an alert (can comment out)
            alert("Sorry too many characters "  + strip);
            // Get all characters up to the limit
            cur = strip.substring(0,maxChars);
            // Replace content with the max amount
            tinyMCE.activeEditor.setContent(oldContent);
        }

        else
        {
            oldContent = content;

        }

            });

        }
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:20:47+00:00Added an answer on June 16, 2026 at 2:20 pm

    All you need to do is

    //find the id of the currently active editor
    var editor_name=tinyMCE.activeEditor.editorId;
    

    then

    //provide regex for list of editors to be matched
    var editors_to_be_matched = /first_editor|third_editor/;
    

    find

    //if active editor matches against the list of editors
    var matched = editor_name.match(editors_to_be_matched);
    

    if

    //active editor does not matches return
    if(!matched) return;
    

    else

    //do character count stuff
    your code here
    

    So here is how it would look like in your case

     ed.onKeyUp.add(function(ed, e) {
        var editor_name =tinyMCE.activeEditor.editorId;
        var editors_to_be_matched = /first_editor|third_editor/;
        var matched = editor_name.match(editors_to_be_matched);
    
        if(!matched) return;
        alert("Do character count stuff here");
        // your code here
    
    
        // What is the max amount of characters you want
        var maxChars = 255;
        var content = tinyMCE.activeEditor.getContent();
        ........
        ..........
    
            });
    

    Here is a DEMO

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a compass. Basically I use an image of a compass
This should address all other data with PHP/MySQL timestamp I have. Basically I use
I have the following: <div id=some-id></div><script src=/script.js type=text/javascript> I'm trying to basically use the
what I want to do is to use something like name=validate[required] basically use it
So basically I use jQuery for alternating row colours by selecting all the tr
I have a class that is its own activity that basically i use to
I'd basically like to use reflection in Powershell, and after dynamically finding the methods
So, I just basically want to use AVFoundation Kit for playing my sound. I
basically my aim is to use JQuery to post back an x & y
Basically, I tried to use twitter-bootstrap-rails and devise gem in my app. However, when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.