Solved

Delete carriage return in string

Posted on 2004-08-06
5
999 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
5 Comments
 
LVL 25

Accepted Solution

by:
devic earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now