christopher.tokar@gmail.com said the following on 1/5/2007 10:22 AM:
Quote:
Hello,
I was wondering if there are any proper, robust libraries or
functions/methods that I don't know of that will escape all the
problematic characters such as single quotes and tabs. I find myself
writing
x = x.replace(/'/g,"\\'"); and the reverse over and over again.
Write a function that does it for you then:
function fixIt(x){
x = x.replace(/'/g,"\\'");
return x
}
myString = fixIt(myString)
And then you have your own library for it.
Quote:
Shouldn't Javascript have a built in method to do this? I know of the
escape() function but I am not sure if this is more for urls. What is
the real world way of storing such an "escaped" variable in a database
that will later be read into a javascript variable? :-/
Having the server "fix it" before saving it and then sending it back to
the client.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -
http://jibbering.com/faq/index.html
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/