0

Hi All,

I have a app.js file. In that for a textarea if i entered data with single qoute
eg: TEST'S it gets stored in DB as TEST\'S to avoid DB problem.

I return the textarea value from java file in json array to app.js. If the array name is like appjsonarray I will access the textarea with its name

appjsonarray.textareaname this will contain the data as TEST\'S
The delimiter(backslash) will avoid termination of Json array.
So i cant remove it. But while displaying how could i display without backslash. I want to display TEST'S in the textarea.

Suggest me plz...
Thanks in advance.

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by anandhikrishnan
0

You can sanitize the text with a simple regular expression, implemented here as a String method.

String.prototype.stripSlashes = function(){
    return this.replace(/\\/g, '');
};

Then call the method with something like this :

...
var myTextArea = document.getElementById("myTextarea");
myTextarea.value = myText.stripSlashes();
...

Where myText is your string containing "... TEST\'S ..." .

Airshow

0
<script type="text/javascript">
var str = "TEST\'S ";
var finalStr = str.replace("\'","'");
</script>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.