views:

95

answers:

4

I have a textbox whose value contains a string with a single quote e.g. Andy's String

<input type='text' value='Andy's String' />

This obviously does not render correctly in a browser. Whats the best way round this?

+4  A: 
<input type='text' value="Andy's String" />

Alternatively:

<input type='text' value='Andy&apos;s String' />
David M
I cant seem to get this escape sequence to work in Internet explorer?
AJM
A: 

Best way is to use double quotes :)

<input type="text" value="Andy's String" />
cdm9002
Surely then the same problem would occur with Andy"s string
AJM
A: 

Hi there.

Use double quotes '' instead of single.

Cheers. Jas.

Jason Evans
Surely then the same problem would occur with Andy"s string
AJM
+2  A: 

Try

<input type='text' value='Andy&#39;s String' />
jhurshman