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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:16:52+00:00 2026-05-23T05:16:52+00:00

I have 2 textarea field. The first field have character limit. When a user

  • 0

I have 2 textarea field. The first field have character limit. When a user type a text in the first field, after the limit reach, the text will automatically continue to the second field.

The problems is when user type or paste a url, the whole url need to be moved to the second field. I thinking to use regex and parse the text in first field in keyup event handler. The pattern that I will looking up is http://…

Does anyone ever have the similar problems, or is there any jquery plugins that could do this?

Update:

Let say the first field have 15 character limit. User type:

'abc '

Then paste a link after the space: http://google.com/?q=test

The field value will become:

'abc http://google.com/?q=test'

Which is more than 15 character. Right now the script will cut the text to become:

'abc http://goog'

and the rest of the text sill go to second field:

 'le.com/?q=test'

The desired action should be that the whole http://google.com/?q=test is moved into second field, leaving 'abc ' in the first field.

My question is, do you have better/efficient way to implement this feature, or there are jquery library out there that have this feature?

  • 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-23T05:16:53+00:00Added an answer on May 23, 2026 at 5:16 am

    I can’t see your problem. Presumably you are going to your character limit, going back to the previous whitespace character (which might be any of a number of characters – space, tab, return, and so on) and splitting the content there. That should account for URLs as they don’t have spaces.

    Edit

    Here is a quick example of what I am talking about:

    <form>
      <textarea id="ta0" style="width: 200px; height 200px;"></textarea>
      <textarea id="ta1" style="width: 200px; height 200px;"></textarea>
      <input type="reset">
    </form>
    <script type="text/javascript">
    
    function moveWords() {
        var el1 = this;
        var el1full = false;
        var el2 = document.getElementById('ta1');
        var charLimit = 20;
        var word, words;
        var v1 = el1.value;
        var s = '';
    
        // If gone over character limit
        if (v1.length > charLimit) {
          words = v1.split(/\s+/);
    
          // Get the value, split into words, add back 
          // one at a time until over limit, then put into
          // next field and change focus
          for (var i=0, iLen = words.length; i<iLen; i++) {
            word = words[i];
    
            if (!el1full && (s.length + word.length) < charLimit) {
              s += (s == '')? word : ' ' + word;
              len = s.length;
            } else {
              if (!el1full) {
                el1full = true;
                el1.value = s;
                s = '';
              }
              s += (s == '')? word : ' ' + word;
            }
            el2.value = s;
            el2.focus();
          }
        }
    }
    
    window.onload = function() {
      document.getElementById('ta0').onkeyup = moveWords;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have one text area <textarea name=message id=message class=text_field style=height:200px; width:500px></textarea> if i type
I have a comment form with a textarea, input text and input radio. first,
I have some text area field in my grails application. I got the following
I have a text input field like text box or text area. I want
I have textarea in my site(link shortening site) i want to user enter some
I have a textarea in which the user enters the following data: Paul:Nine, Rome
I have a form that consists of: 3 text boxes (first two are required
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
I have a textarea with many lines of input, and a JavaScript event fires
I have a textarea where I measure the textWidth and textHeight to make sure

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.