I have an HTML textarea element. I want to prevent a user from entering any HTML tags in this area. How do I detect if a user has entered any HTML a textarea with JavaScript?
Thank you
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.
firstly, bear in mind that you’ll need to re-validate on the server side, since anyone can fake a http post, and if they have javascript disabled then of course you have no control 🙂
what i’d do is
and for the javascript
another way to do this would be to replace < and > with < and > on the server side, which is the better way because it’s secure and people can still frown >:)
[edit : you can make the regexp as clever as you like, if you want to only detect certain tags for instance]