code8
code8

Reputation: 103

How to escape apostrope value

My code is like this

<%
var publicjirasummary = ex.getAttribute("jiraInformation_publicjirasummary");
var cleanDatapublicjirasummary = (publicjirasummary == null)? "" : publicjirasummary;
%>

<input type="text" id="publicjirasummary" name="publicjirasummary" class="round full-width-input" value='<% print(cleanDatapublicjirasummary);  %>'/>   

This code works fine ,but the problem occurs when user enter string like follows "Public Jira Summary field value can't displays"

Then results display only following part of the string

"Public Jira Summary field value can"

Problem occurs only with " ' " mark.How to change code to escape " ' " this character in a comman way?

Upvotes: 1

Views: 104

Answers (2)

Dakshika
Dakshika

Reputation: 1714

Try this

var str = "Public Jira Summary field value can't displays"
str = str.replace(/'/g, '');

The reason your version wasn't working is because str.replace returns the new string, without updating in place.

Upvotes: 0

zeppaman
zeppaman

Reputation: 854

Have you tryed with traditiona escape like:

\'

Upvotes: 2

Related Questions