Click to See Complete Forum and Search --> : Escaping double quotes in input value


thejoker101
08-12-2003, 08:51 AM
Part of my messaging system involves putting unknown text into the value=" " of an input type="hidden" element. I truncate the text if there is a double quote in there. So, my question is, how do escape a double quote when it is set in the value attribute? doing \" doesn't seem to work, should I convert it to " (I think that's it for double quote, doesn't matter I could look it up if i need to) ?

Thanks.

Jeff Mott
08-12-2003, 11:46 AM
You should transpose all HTML special characters to their corresponding character entities.

HTML Special Chars:
" & ' < >

pyro
08-12-2003, 11:52 AM
With the double quote specifically being:

&amp;#34; or &amp;quot;

Others can be found at http://www.w3.org/TR/html4/sgml/entities.html#h-24.4.1

thejoker101
08-12-2003, 11:54 AM
for reference, i had the &-code up there for the double quote, it just converted it to the double quote, haha, whoops.