r k

r k

  • NA
  • 111
  • 16.6k

How to check apostrophe in a inserted string

Jun 18 2021 2:27 PM

How will i find an aprostophe (single quote ) in jquery if user has in it's message . If it is there the replace or escape because sql server doesnot accept single quotes.

If message does not contain single quote the i want to send message as message because message may have image files , tables or videos .

i am trying this 

var message = contents.replace(/[!'()*&"<>]/g, escape);

but it is saving like below in db & giving user 

%3Cp%3Ethis isn%27t good it%27s not saving%26nbsp;%3C/p%3E

Also if i will not put a check then it saves the video's the same way 

Please help 


Answers (4)