Ask a Jedi: Help in preserving user input

A reader asks:

I want to create a discussion board where I can retain the carriage returns that my users have entered - how can I pull their entries from the Database and retain the carriage returns without using the <pre> tags?

Out of the box, ColdFusion provides us with a paragraphFormat() function. This will correctly format blocks of text in paragraphs, inserting a P tag at blank lines. However, it won’t correctly notice simple line breaks, like in an address. You can get around this by using a user-defined function like paragraphFormat2, written by Ben Forta. This UDF simply looks out for line breaks and inserts a BR tag. I use this on my Galleon ColdFusion forums.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments