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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:54:44+00:00 2026-06-12T12:54:44+00:00

After having asked this question in the DB section and being adived to ask

  • 0

After having asked this question in the DB section and being adived to ask it here, here is my problem:

I have the problem, that I have a long text that is being read from a database. The text itself is just a one liner. The problem is that it needs to be broken at exactly 80 chars even when in the middle of a word.

HTML or other languages will make the line break if the next word doesn’t fit in the remaining chars and that is not what I want. The pages are done in jsf.

For example:

textarea= cols: 8 rows: 3

input= break these texts

normal:

break 
these
texts

what I need:

break th
ese text
s

Any ideas on how I can do this?

  • 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-12T12:54:46+00:00Added an answer on June 12, 2026 at 12:54 pm

    you can use the below function just pass the string (you want to brake after every 80 char) to the function

    function breakText(str)
    {
      i=0;
      outputStr="";
      str= str.replace(/(\r\n|\n|\r)/g," ");
    
     while(i<str.length)
      {
       outputStr += str.substr(i,80) +"<br>"; // replace br with any line break you want
       i=i+80;
      }
      return outputStr
    }
    

    NOTE : this function will replace all the line break and insert a <br> after every 80 char

    Working DEMO

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

Sidebar

Related Questions

I realize that this question has been asked and has been answered here but
Im having trouble understanding class relationships after being asked to research it further, would
After having my last question answered , I have never see the preventDefault(); function
This question is in relation to another question asked here: Sorting 1M records I
I decided to put an AWS related Q here after having asked on aws
So I know this question have been asked a lot , but I don't
I have asked this question couple times, but non of the suggestions seems to
This question was asked in another post at Facebook iframe app being redirected out
Disclaimer: I know this type of question has been asked here before, I just
Helo Experts again. I have asked a question similar to this in the past.

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.