Avatar of mahaq
mahaq
Flag for United States of America asked on

String Manipulation - Issue in showing long unterminated user entry into 2 lines on IE7.


I am grabbing a val from the jsp input hidden tag.
and taking its value thru the Id.

I have to break the line at 30 characters when the value is returned.

Doing all this in JQuery  DOM ready...

var chkIfStd = $('#chkIfStd').val(); // check for standard
      if(!chkIfStd ){
            $('#TextLink').html(wrapText($('#TextLink').text()));
             
      }


There is a method which wraps the text (written by somebody)


function wrapText(strng) {
      var strLength = strng.length;
      var maximum = 30;
      var myString;
      if (strLength > maximum) {
            myString = myString.substring(0,maximum)+'<br />'+myString.substring(max);
      }
      return myString;
}


Tried using word break in css too but nothing helped, looks like I am not using it right...the function works fine at other places, or may be I need a Regex. (starting with character and not a number or any special character in the string).


Scripting Languages

Avatar of undefined
Last Comment
mahaq

8/22/2022 - Mon
Terry Woods

I can provide you with a regex pattern if it turns out to be the best way - I'm not exactly clear about what you want done with it though, as you seem to be requesting both line breaking and matching a value "starting with character and not a number or any special character in the string".

A pattern for validating a value "starting with character and not a number or any special character in the string" might be:
^[a-zA-Z][a-zA-Z ]*$
which considers anything other than a letter or space to be a special character.

I've interpreted that requirement as:
"starting with character, and not a number or any special character in the string"
rather than:
"starting with character and not a number, or any special character in the string"
mahaq

ASKER
Your regex is fine, I got it.

Now I need help on breaking a long unterminated string rendering in the IE7. If you can do that its much appreciated.

SOLUTION
Terry Woods

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
mahaq

ASKER
I tried your suggested, not getting it right.

Are you aware of this in JS, the one given below is a PHP wordwrap

$string = "ACTGATCGAGCTGAAGCGCAGTGCGATGCTTCGATGATGCTGACGATGCTACGATGCGAGCATCTACGATCAGTCGATGTAGCTAGTAGCATGTAGTGA";

$mystring = wordwrap($string,30,"<br>",true);

I mean the method/api for wordwrap.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
mahaq

ASKER
I used something like this..

var idName = $('#myIdLink').text();
$('#myIdLink').html(idName.substring(0, 30)+"<br>"+idName.substring(35, idName.length) );

But your idea was great.

Thanks for your help..