Nov 7, 2009

How Do I Restrict Html Tag Entry In Textarea ?

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > JavaScript

How Do I Restrict Html Tag Entry In Textarea ?

sazz
On my site people may use some html code to enter into a textarea. However I don't wanna let them display images and links to other pages.
To be exactly, I only want them to use:

<P> & </P>
<EM> & </EM>
<U> & </U>
<STRONG> & </STRONG>
<P align=center> & </P>
<P align=left> & </P>
<P align=right> & </P>
<P align=justify> & </P>

So I want to delete all other html tags & javascript, or anything else they can put in. What lines do I need to make sure they only use the tags above and for the rest plain text ?

Comment/Reply (w/o sign-up)

Fate
the easiest way is to provide ur own tags...
[/center] instead of <p align=center></p> etc....
then u cancel html completely and convert ur own tags to the apropriate values when displaying...

but if u insist on keeping it html, though i see no reason why,
u can search and replace every tag u wish to keep with something like the [center]
using regular expressions (not so hard)..
the killing all html, and then converting it back...

Comment/Reply (w/o sign-up)

Houdini
Not knowing what software you are using or how your site is set up it would be hard to give you any advice on how to filter, or limit the use of certain tags, you already have the <P> covered it will wutomatically allow all <P> tags with attributes that you must specify such as the alignment feature which is an attribute of not only the <P> tag but others as well duch as the <DIV> or <SPAN> I suppose you could create a form that produces button that apply only those features you want but not knowing how you site works it is hard to tell you much more.

A link to the site or perhaps some code that shows us just what you have right now would get more responses and probably a means to do what you want.

See the Code below that defines some image icons for use in posting within a form.
HTML
<img src="images/url.gif" border="0" accesskey='h' value=' http:// ' onclick='tag_url()' name='url' onmouseover="hstat('url')" />
<img src="images/img.gif" border="0"accesskey='g' value=' IMG ' onclick='tag_image()' name='img' onmouseover="hstat('img')" />
<img src="images/email.gif" border="0" accesskey='e' value=' @ ' onclick='tag_email()' name='email' onmouseover="hstat('email')" />
<br />
<img src="images/quote.gif" border="0" accesskey='q' value=' QUOTE ' onclick='simpletag("QUOTE")' name='QUOTE' onmouseover="hstat('quote')" />
<img src="images/code.gif" border="0"accesskey='p' value=' CODE ' onclick='simpletag("CODE")' name='CODE' onmouseover="hstat('code')" />
<img src="images/list.gif" border="0" accesskey='l' value=' LIST ' onclick='tag_list()' name="LIST" onmouseover="hstat('list')" />
<br />

 

 

 


Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)


See Also,

*SIMILAR VIDEOS*
Searching Video's for restrict, html, tag, entry, textarea
advertisement



How Do I Restrict Html Tag Entry In Textarea ?

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com