Solved

Remove hard carriage returns

Posted on 2004-04-06
8
199 Views
Last Modified: 2010-04-06
I have a text area box where users can describe a problem their having, but the problem is when the data is posted to my autoresponder, the autoresponder doesn't like hard carriage returns. Is it possible to keep all data entry on one line, so change something like this:


Join us for a brief burst of daily entertainment.

Jokes, toons, funny and strange links, news to amuse and more.

Join now, it's free.


to this when the user submits:

Join us for a brief burst of daily entertainment. Jokes, toons, funny and strange links, news to amuse and more. Join now, it's free.
0
Comment
Question by:lserrano
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 7

Expert Comment

by:ramesh12
ID: 10770136
Use join command


Here take a look at this

http://www.learnasp.com/learn/stringjoin.asp

Instead of "," you use space " "
0
 
LVL 7

Expert Comment

by:ramesh12
ID: 10770142
Oops sorry , not space use VBcrlf
0
 

Author Comment

by:lserrano
ID: 10770182
I'm looking for some JS to do this. Does anyone have a JS script to handle this?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Expert Comment

by:frox
ID: 10772692
Hi, I think you are looking for something like this:

This goes into the <head> section:

<script language="javascript">
function nocr()
{
 with (document.form1)
 {
  for (var i=0; i < elements.length; i++)
  {
   if (elements[i].type == 'textarea')
   {
    elements[i].value=elements[i].value.replace(/\r\n/g,' ');
    elements[i].value=elements[i].value.replace(/\n/g,' ');
    alert(elements[i].value);
   }
  }
 }
}
</script>

Change the <form> tag into:
<form name="form1" onsubmit='nocr()'>

This will change newlines to a space for all the TEXTAREAs in the form.

The two replace might seem redundant, but the first one works with IE, the second works with Netscape (at least in a not too old Netscape)

hope this helps
0
 

Assisted Solution

by:frox
frox earned 50 total points
ID: 10772707
Oops, and remove the alert(), it was there for debugging purposes :-)
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 200 total points
ID: 10773406
My version is simmelar to frox's, except it is less hardcoded names:

<html>
<body>
<form>
<textarea name="UserInput" onChange="this.value=this.value.replace(/[\n\r]+/g,' ')">
</textarea>
<input type=submit>
</form>
</body>
</html>

Two notes: the onChange is always executed before submit. By onChange does the user also see the change on leaving the textarea for other elements input. If that confuses your user, then the same line can also be executed for all textareas in onSubmit, like frox did.
If you donot want the blanks for newlines, then add something else for your server side, for example a semicolon, a <br> or a special character.

My first guess was to use WRAP=SOFT
The description does state that browser is NOT sending the CR to server, but it seams not to be true.
Give that wrap also a try.
Like this:
<textarea name="UserInput" WRAP=SOFT>
</textarea>

Good luck,
Zvonko

0
 

Author Comment

by:lserrano
ID: 10774995
Thanks Zvonko. You did it again. ;-)
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10775156
:-)

Cheers,
Zvonko

0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Collapseable list of URLs. 10 130
 shows up in Outlook, not OWA or on phone 3 69
Specific format 21 198
React or Angular? 6 73
When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
The viewer will learn how to dynamically set the form action using jQuery.
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…

777 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