Solved

Delete carriage return in string

Posted on 2004-08-06
5
1,009 Views
Last Modified: 2007-12-19
I would like a javascript function which will replace a carriage return with an empty space.
Thanks
0
Comment
Question by:MichaelMullin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 25

Accepted Solution

by:
devic earned 50 total points
ID: 11739791
try this:
=======
<form>
<textarea name=t style=width:300px;height:300px></textarea>
      <input type=button value=OK onclick='this.form.t.value=this.form.t.value.replace(/\r\n/g,"")'>
</form>
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11739876
Hi

devic's should work. Of course, you can be more compliant by including all of his attributes in quotes, but it'll work. I'm thinking you want it to be for Unix, am I right? Well, if you only want to delete the \r, use:

this.form.t.value=this.form.t.value.replace(/\r/g,"") which is basically the same as devic's above

Regards,
Zyloch
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 11742010
Small improvement of devic's code would be also to replace [\r\n]  for example on Linux\Unix\Mac browsers.

Like this:
<form>
<textarea name=t style=width:300px;height:300px></textarea>
     <input type=button value=OK onclick='this.form.t.value=this.form.t.value.replace(/[\r\n]/g,"")'>
</form>

0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question