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 8767919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:56:23+00:00 2026-06-13T16:56:23+00:00

I did a search and was not able to find it. We have a

  • 0

I did a search and was not able to find it. We have a Spark TextArea with maxChars=”3900″. But it doesn’t work when copy/paste to the text area. I tried to add this to the changingHandler:

 if (ta.text.length > 3900)
        {
                        Alert.show("The maximum characters length is 3900. Please limit the characters to the max limit");
                        ta.text = ta.text.substr(0, 3900);
                    } else 
                    {
                        if (event.operation is PasteOperation)
                        {
....//Other logic
                        }
       }

The problem is it does not work all the time. The Alert shows up only some times when it is over 3900 chars. Not sure why. I also added the same to the changeHandler as well. But that does not get triggered at all.

Please let know what I’m missing. I need to show an alert & trim the chars to the max each time it goes above the max limit.

Thanks

Harish

  • 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-13T16:56:25+00:00Added an answer on June 13, 2026 at 4:56 pm

    First, we need to clear one thing: when the changing handler is triggered, that’s means: the text is changing, but the change not apply yet.

    if the text in your textare is “”(empty), now, I paste 1600 chars, the changing handler invoked, the length of the text is still 0, because it’s changing, not change.

    so now, if you got a change handler, when you trace the length, it should be 1600.

    but, if you use “event.preventDefault();” in your changing method, and do nothing to change the text in your changing handler, your change handler should not be triggered.

    so, my suggestion is :

    1. Using changing handler is correct.
    2. in the handler, get the text in clipboard, then you can get the length of the text in clipboard, with this length + textArea.text.length, you’ll get the length if the paste processed.
      if the total lenght is bigger than your limition, you can prevent the event, and do whatever you want to do.

    here is some code for you:

    protected function textArea_changingHandler(event:TextOperationEvent):void
            {
                trace(event.type + " - " + textArea.text.length); //  this length is befor the paste
    
                if(event.operation is PasteOperation) {
                    // Text in the clipboard.
                    var textPaste:String = Clipboard.generalClipboard.getData(ClipboardFormats.TEXT_FORMAT) == null ? "" : Clipboard.generalClipboard.getData(ClipboardFormats.TEXT_FORMAT) as String; 
                    // this length is after the paste(if the paste will complete)
                    var totalLength:int = textArea.text.length + textPaste.length; 
                    trace("String length after Paste: " + totalLength);
    
                    if(totalLength > 3900) {
                        event.preventDefault();
                        textArea.text += "[Paste:" + textPaste.substr(0, 2) + "]"; // process your text here. 
                    }
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I did a lot search already but couldn't find a straight anwser. I have
I have search all over the web but could not find answer to this
I did search the forum and did not find a similar question. I'm looking
First of all, I did a search on this and was able to find
I did a search on this, but didn't find a question that quite matched
Please note that this is not homework and i did search before starting this
just to put it out there -I really did search and try to find
I did a search on the elements of the list, but the problem is
I have been searching the internet, and couldn't find what I'm looking for but
I did search, and got a cloeset answer form How can I automatically close

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.