0

Hi Guys,

I just wonder anybody here know how to strip html from the text box ?
I just want to make sure that at the time user post something,they dont
insert any HTML or javascript ...

thanks

Johnny

Edited by Ezzaral: Snipped url. Please restrict personal links to your user signature.

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by crishjeny
0

It can be difficult to specifically strip code from submitted text in a text box...

Well... not 'difficult' but cumbersome :)

One thing I might recommend would be that you look into Regular Expressions as, using that, you can specify strings to be excluded/filtered from submitted text (such as URLs and script openers). The only drawback with the RegEx method is that you kind of have to be specific about the things you are excluding (ie: if you don't specify it, it won't be excluded).

Another thing you can combine with RegEx filtering is SubString segments (to catch everything between the opening and closing braces of an HTML or script tag for example). Simply grab everything from the first IndexOf to the following closing brace and snip it out. This can add a bit of heft to your coding however and also means a lot more room for error if not coded correctly.

Hope this helps :) Please remember to mark the thread solved once your issue is resolved.

Edit: One thing I forgot to mention is that RegEx is case sensitive so you either need to utilize separate RegEx values for both capital and lower case or convert the input entirely to upper/lower prior to utilizing RegEx on it (which can be detrimental to the valid input from the user).

Edited by Lusiphur: n/a

0

wots the problem big guy...

validate your textbox on client side..which is a part of formality.

now if someone by passes the client side validation then

you gotta take care of those things on the server side validation.

and why do you have a problem with HTML and Javascript Tags in the Textbox

on server side use HTMLEncode/ Decode function, i'm not sure which functin.

it will nutralize the whole thing..

hope that helps

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.