Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6333651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:30:22+00:00 2026-05-24T18:30:22+00:00

How do I add security to a textarea so the only thing that a

  • 0

How do I add security to a textarea so the only thing that a user can enter (besides normal text) is a new line.

Example:

<textarea>
For some reason
I want this on 2 lines
</textarea>

Any other type of tags should not be allowed. I have done ALOT of tests with php security functions like htmlentities, strip_tags, nl2br, etc and I have not found anything that could do what I want. Any ideas?

UPDATE: I don’t have any examples of how htmlentities did not work for me, because that is from past experience, but if someone can provide me with an example of how to use htmlentities to do this, that would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:30:22+00:00Added an answer on May 24, 2026 at 6:30 pm

    What you need to do is define a whitelist of allowable values which will include upper and lower alpha characters, line returns then anything else you want to allow (punctuation, numbers, etc.) A regular expression is easy enough to do this with and you’ll need to validate the contents of the text area against this on submission.

    Also, make sure you always run this on the server side. You can run it client side as well but you must make sure the mechanism can’t be circumvented at the browser hence the server validation dependency.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Spring Security. How do I add an event listener which will
I need to add -Djava.security.policy=myPolicyFile so that my RMI jar would work. Or is
I am trying to add more security to my user authentication sessions. When the
How to in http://msdn.microsoft.com/en-us/library/bb472488.aspx add a security. For example I want to post data
I'm trying to add some security to my ASP.NET 1.0 MVC app (VB), but
I am trying to add some security to my computer at home and would
All, I am trying to add Spring Security(3.0.7) to my web application(Spring 3.0.6, Tiles
I am trying to add security of GET query to exec function. If I
I would like to add integrated windows security to one of my views, is
I am getting the below exception when I'm trying to add security headers to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.