Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Replace a carriage return in TEXTAREA with chr(13)?

Posted on 2003-03-23
Medium Priority
Last Modified: 2008-02-01
I am making a Web site for a group within my local church, and the leader is fairly computer-ILliterate.  But, he wants a page where he can add content by filling out a form.  I have created a form for him where he can type some text in a TEXTAREA form, PLUS add formatting by clicking button images next to the box.  He clicks a button (for example, the "B" Icon for Bold/UnBold), and the corresponding mark-up is added to the end of the textbox so he can keep typing.  Here's my problem:

When he presses "Return" on his keyboard to make a carriage return, it appears in the text box, but does not transform to whitespace after it is filled out.  In other words, his words before and after the carriage return are stuck together - right next to each other.  Is there a way in ASP or JavaScript to detect the "Enter" key and insert a <br> tag there instead?  Or at least, when he submits it, have a code that replaces all carriage returns with <BR> tags?  Please reply m_r_productions@hotmail.com
Question by:m_r_productions
  • 2

Accepted Solution

zombeen earned 200 total points
ID: 8193083
i 've not checked the constants, but u can try this
strText = Replace(Replace(request.form("textarea"), vbCrLf, "<br>"),chr(10), " ")

strText =replace(strText,chr(13),"<br/>")

You might hav to check the values for the desired result... but this is the basic concept to do this

LVL 15

Expert Comment

ID: 8193141

Or at least, when he submits it, have a code that replaces all carriage returns with <BR> tags?

You can use the replace function...

tmptextarea = Replace(request.form("textarea"), "<br>", "vbcrlf")

Below is related link regarding replace method...



HAppy programming...

Author Comment

ID: 8193181
Hey zombeen you hit the nail right on the head.  Good answer, I tried it and it worked very well.  Thank you for the quick response, too.

gladxml had a valid answer, too, except I wasn't replacing the <br> tag with chr(13).  But the answer in itself is still very useful information.  Thanks for responding, gladxml
LVL 15

Expert Comment

ID: 8193246

Glad to be of help...


Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

572 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