View Full Version : inverted commas
ooiooipig
04-08-2003, 07:57 AM
hi anyone out there can tell me how to write " " in a text area?? thanks!!
Spudhead
04-08-2003, 09:40 AM
<textarea>& q u o t ; & n b s p ; & q u o t ;</textarea>
works for me (without the spaces..)
ooiooipig
04-08-2003, 09:52 AM
ok, but this is not what i needed. thanks anyway!! :)
I need to find out if users enter something in the textarea, they include the quotation sign, it will interrupt my codings. how can i ensure that this will not happen??
Spudhead
04-08-2003, 12:25 PM
Aha. You mean getting the value back out?
<%
var myTextAreaVal=escape(request("myTextAreaName"))
%>
any help?
oracleguy
04-08-2003, 04:41 PM
Or use a modification of the single quote function that whammy has as a sticky:
Function CDQ(byVal str)
If IsNull(str) Then str = ""
CDQ = Replace(str,"""","""""")
End Function
That work?
ooiooipig
04-09-2003, 01:43 AM
hi oracle guy, so where do i call this function?? should i put the codes in the server side or client side??
oracleguy
04-09-2003, 02:15 AM
You'd do it serverside.
Like:
<%
Dim strTest
strTest=CDQ(Request.Form("textarea"))
%>
And you also gotta put the function some where on the page surrounded by <% %>.
ooiooipig
04-09-2003, 02:27 AM
ok, so you mean i just put in this code
<%
Dim strTest
strTest=CDQ(Request.Form("textarea"))
%>
in the server side then can already??
glenngv
04-10-2003, 02:19 PM
it's not only quotes but other characters that may be interpreted as html or script.
<textarea><%=server.htmlencode(request.form("textarea"))%></textarea>
ooiooipig
04-11-2003, 03:22 AM
now i'm using the
<%= server.urlEncode(Request("vFreqVol"))%>
however, i do not know how to decode it...
can anyone please advice??
whammy
04-11-2003, 11:53 PM
Um, glenngv said Server.HTMLEncode() - not Server.URLEncode().
Server.URLEncode() is only handy when you're using variables in Response.Redirect (to escape said variable), at least from my experience.
Server.HTMLEncode() is something that you MUST understand - so if you're not familiar with it I would devote some time to experimenting with it (google it!), since most ASP developers either don't understand how to use it or they misuse it a couple of times and then never use it again (not realizing they don't understand how it's to be used!).
Heh... how many times did I say "use" above? Anyway...
Server.HTMLEncode() has also survived the transition to .NET - which in itself proves its usefulness (dang, there's that "use" word again")...
If you don't use (lol) it, people can easily break your forms, not to mention possible other nasties, that I won't detail here. :(
P.S. The reason I'm not detailing what Server.HTMLEncode() is for and how to use it, is because you need to learn it! So go learn it (and experiment with it to see what it does), if you don't know. Basic textarea example:
<textarea name="blah" cols="30" rows="30"><% = Server.HTMLEncode(blah) %></textarea>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.