473,386 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Preventing people from entering HTML in textarea

Hi,

I have a text area and I want prevent people from entering HTML text
in the text area.

Someone putting "</textarea></tr><img
src="http://www.xxx.com/images/pic.gif">" in the textarea will
manipulate the page if the page was revisited.

Does anyone have any ideas?

Thanks in advance

Angela
Jul 20 '05 #1
3 1498
Angela wrote on 05 mrt 2004 in comp.lang.javascript:
I have a text area and I want prevent people from entering HTML text
in the text area.

Someone putting "</textarea></tr><img
src="http://www.xxx.com/images/pic.gif">" in the textarea will
manipulate the page if the page was revisited.


only if you reenter that string from serverside,
so that asks for a serverside solution,
depending on your server language.

clientside it could be done by:

onchange=
"this.value=this.value.replace(/</g,"&lt;")

[not tested]

but clientside JS could be manipulated by a client too.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #2
I will be using ASP, so maybe I will have to use regExp to solve this
problem
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
Angela Lam wrote:
I will be using ASP, so maybe I will have to use regExp to solve this
problem


Remove all markup:
str = str.replace(/<\/?[^>]*>/g, " ");

Optionally Server.HTMLEncode the data.
--
Andrew Urquhart
- FAQ: http://jibbering.com/faq
- Archive: http://groups.google.com/groups?grou...ang.javascript
- Reply: www.andrewu.co.uk/about/contact/
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: JimO | last post by:
I teach HS computers and one of my kids has a web site with a textbox of info that the user can scroll down and read. The problem is that users can also enter text into it. Is there a way, or a...
18
by: Elroyskimms | last post by:
I have a table using an identity column as its Primary Key and two columns (table reduced for simplicity) EmployeeNumber and ArrivalTime. CREATE TABLE ( IDENTITY (1, 1) NOT NULL , (10)...
8
by: alanstew | last post by:
With the body tag calling out 'window onload', a function with a 'window.open' fails at the 'window.open' line. If I cut out the body tag, the function executes as normal. At first I thought it...
5
by: www.douglassdavis.com | last post by:
I have an idea for preventing sql injection attacks, however it would have to be implemented by the database vendor. Let me know if I am on the right track, this totally off base, or already...
1
by: monomaniac21 | last post by:
hi all! how can i enter html and php into a db and display this within a TEXTAREA without it being processed as code? do i need to replace characters like <? with something else like say <..? or...
5
by: Schraalhans Keukenmeester | last post by:
I want to build a very basic online text editor, to allow customers to modify their own sites' html content using a simple form with textarea element. I read the HTML file like so: <?PHP ...
1
by: gomzi | last post by:
hi, Is there any way for preventing the users from entering html code in the form fields? thanks, gomzi.
1
by: bizt | last post by:
Hi, I have a webpage where Im creating AJAX type requests by loading dynamic pages containg JavaScript into hidden iFrames. The reason I am opting for this method over XmlHttpRequest object...
12
by: MikeB | last post by:
I created a small website for a friend. On this website he has a contact page where people can send him email. When I wrote this page I checked some tutorial pages and they warned about certain...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.