This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes how do i restrict HTML tags in textarea Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "how do i restrict HTML tags in textarea" Watch "how do i restrict HTML tags in textarea" New topic
Author

how do i restrict HTML tags in textarea

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 744
How do i restrict HTML and other scripts tags in textbox or textarea ?

i mean user can write HTML and other tags like [html] abc [/html]
but in out put there should be no effect.

the effect should be like

System.out.println("mymethod1()");

o/p

mymethod1()
[ December 12, 2006: Message edited by: Jigar Naik ]

Jigar Naik


Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Look for HTML control characters (IE: <, >, &) and either escape them or reject the post and send the user an error message.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 744
how do we go thru individual character of a textarea ???
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

How are you retrieving the form fields now?
Post your the servlet or JSP code that you're using.
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 744
String s1 = req.getParameter("field_textarea");

I want to use java script but i m new to java script.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

OK, this forum is for JSP (server side).

To do what I mentioned earlier, look at Java's String object.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html
It has several methods for replacing characters and substrings.

Javascript is a client side technology (interpreted in the user's browser).
We have an HTML/Javascript forum where these technologies are discussed.
If you would like this thread to be move to that forum, let me know and I will move it for you.
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 744
Yes i want all that validation stuff to be done on client side and thats you i maintaned java script.

please move this topic to the right place.

thanks a lot.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15362
    
    6
You STILL have to do it on the server

onsubmit of the form you can do replace(/</gi,"<") and so on.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how do i restrict HTML tags in textarea
 
Similar Threads
Saffari does not support html content on textarea
trouble with textarea
Help Please!!!
line height
Saffari browser does not support the html content on textarea