We help IT Professionals succeed at work.

Remove hard carriage returns

Medium Priority
223 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.
Comment
Watch Question

Commented:
Use join command


Here take a look at this

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

Instead of "," you use space " "

Commented:
Oops sorry , not space use VBcrlf

Author

Commented:
I'm looking for some JS to do this. Does anyone have a JS script to handle this?

Commented:
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
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Systems architect
CERTIFIED EXPERT
Top Expert 2006
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks Zvonko. You did it again. ;-)
ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
:-)

Cheers,
Zvonko

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.