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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:13:14+00:00 2026-05-24T08:13:14+00:00

I am simply wanting to stop a user entering carriage returns in a TextArea.

  • 0

I am simply wanting to stop a user entering carriage returns in a TextArea. I have been experimenting with the ‘restrict’ property in the TextArea but cant seem to work it out.

I have the following code:

<mx:Canvas id="cvs1" label="Panel 1" width="100%" height="100%" creationComplete"addEvtListnerOnPlaceText()" backgroundColor="#FFFFFF">
    <mx:TextArea id="txtP1T1" x="10" y="176" text="{placeName}" width="210" textAlign="center" color="#DC0000" restrict="this is where I need some help"/>
</mx:Canvas>

I’m not sure if the restrict property will cover this or not but any help will be much appreciated.

I’ve now managed to get something working:

    private function addEvtListnerOnPlaceText():void{
        txtP1T1.addEventListener(KeyboardEvent.KEY_DOWN, onKeyEventDown);
        txtP1T1.addEventListener(KeyboardEvent.KEY_UP, onKeyEventUp);
    }

    [Bindable]
    public var tempString:String;
    private function onKeyEventDown(e:KeyboardEvent):void
    {
        var character:String = String.fromCharCode(e.charCode);

        if (e.keyCode == 13)
        {
            tempString = txtP1T1.text;
            KeyboardEvent.KEY_UP;
        }

    }
    private function onKeyEventUp(e:KeyboardEvent):void
    {
        var character:String = String.fromCharCode(e.charCode);

        if (e.keyCode == 13)
        {
            txtP1T1.text = tempString;
        }

    }

The only issue now is that if you hold return down, it clears the first carriage return and then keeps adding as long as you hold it down. I need a way to stop this happening without just losing focus on the text area.

  • 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-05-24T08:13:15+00:00Added an answer on May 24, 2026 at 8:13 am

    No experience with flex3, but after a cursory investigation based on the idea of using an event-driven algorithm it seems you could utilize TextEvents and just remove any newlines/carriage returns in the inputted text before passing to the TextArea.

    Alternatively, you may want to take a look at KeyboardEvents.


    However, it seems that utilizing the restrict property would indeed be simplest, as you can just set it to "^\r" and that would exclude carriage returns and only carriage returns from being entered. (Of course I’d recommend using "^\r\n" instead, to provide overall newline protection from both carriage returns, linefeeds, and any combination of the two.)

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/TextArea.html#restrict

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

Sidebar

Related Questions

It's the first time I have used ajax. I am simply wanting to pass
This is not wanting to work for some reason. I'm simply trying to have
I have a simple submit button. I am wanting to align it to the
Simply, I'm just looking to get a list of connected remote disks. I have
I am wanting to create a page that can load a property file into
We have a 3rd Party Piece of software that I'm wanting to apply some
I have a for loop displaying XML data from the last.fm API. Im wanting
I am fighting a recalcitrant VS2008 DataSet designer, it seems. I have been trying
I have used a few different tooltip plugins over the years, but I think
So i am simply wanting to output the current viewport of the document $('#dimensions').text(window.innerWidth

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.