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.
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.
Oops sorry , not space use VBcrlf
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
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
elements[i].value=elements
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Zvonko. You did it again. ;-)
:-)
Cheers,
Zvonko
Cheers,
Zvonko
Here take a look at this
http://www.learnasp.com/learn/stringjoin.asp
Instead of "," you use space " "