How can i handle user inputs with textarea, i need to strip user entered html tags, store text somewhere and display it back in a webpage.
I also need to take care about line breaks
Any best practices without using <pre> tag ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You can always do a find-replace of
\nwith<br />to preserve line breaks.However, stripping html is a bit trickier. The easiest thing to do is replace
<and>with<and>. But that doesn’t actually strip the html, it merely forces it to render as plain text instead of html.You could use a regex replace to remove
<anything>but that has many potential pitfalls.