View Full Version : Resolved How to prevent people from posting HTML code in textarea
egturnkey
04-13-2009, 02:41 PM
Hello,
I'd like to ask a question ..
How do i prevent people posting HTML codes in an textarea ?
thanks it really will helps me alot
Snookerman
04-13-2009, 04:09 PM
You could use JavaScript like this:
<textarea onkeyup="javascript:this.value=this.value.replace(/[<,>]/g,'');"></textarea>
This won't work if JavaScript is turned off so you need to do server side checking as well.
Good luck!
egturnkey
04-13-2009, 05:55 PM
thanks very much , it now works perfect.
As Snookerman said, it won't work if javascript is turned off. I suggest using PHP's htmlentities().
Snookerman
04-13-2009, 06:12 PM
You're welcome, glad to help!
Good luck with your site!
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.