Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Delete carriage return in string

Posted on 2004-08-06
5
Medium Priority
?
1,017 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 200 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…
Suggested Courses

885 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