0

I have a string like this: $string1 = DO"C OR $string2= MV'C and I have a input text Like This

<input type="text" value="">

if I am placing the string MV'C Like This

<input type="text" value="MV'C">

every thing is ok but if I put the DO"C String it brakes because the "

is there any solution for this?

2 Answers2

0

I think your problem can be solved in two ways.

  1. using single quotes to wrap the text.

<input type="text" value='DO"C' />

  1. using HTML Entities : https://www.w3schools.com/html/html_entities.asp

<input type="text" value="DO&quot;C" />

keshav
  • 135
  • 4
0

Always escape special symbols in javascript such as ' or " with a backslash like so \" or \'

as for html:&#34; for doublequotes " and &#39; for single quotes '