| 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
|
|
You STILL have to do it on the server onsubmit of the form you can do replace(/</gi,"<") and so on. Eric
|
 |
 |
|
|
subject: how do i restrict HTML tags in textarea
|
|
|