[thelist] PHP: How to detect a line break in a textfield

Chris Marsh chris at ecleanuk.com
Tue Feb 25 08:07:00 CST 2003


> Probably a very simple question for the pro's but a very
> complicated task for me: Could you tell me how I can detect a
> line break that was imposed by the user by pressing the
> "Enter" or "Return" key when filling a multi line textfield
> in an HTML form?
> I believe in ASP its something like "CRLF" or so.

vbCrLf in VB[Script]. Assuming you're using VBScript with ASP, then you
could (for example) substitute html tags for line breaks thus:

sText = Request.Form("Text")
sText = Replace(sText, vbCrLf, "<br />")


sText = Replace(sText, vbCrLf & vbCrLf, "</p>" & vbCrLf & "<p>")
sText = Replace(sText, vbCrLf, "<br />" & vbCrLf)
sText = "<p>" & vbCrLf & sText & vbCrLf & "</p>" & vbCrLf



Chris Marsh

More information about the thelist mailing list