Link to home
Start Free TrialLog in
Avatar of lserrano
lserrano

asked on

Remove hard carriage returns

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.
Avatar of ramesh12
ramesh12

Use join command


Here take a look at this

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

Instead of "," you use space " "
Oops sorry , not space use VBcrlf
Avatar of lserrano

ASKER

I'm looking for some JS to do this. Does anyone have a JS script to handle this?
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
SOLUTION
Avatar of frox
frox

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Zvonko. You did it again. ;-)
:-)

Cheers,
Zvonko