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.

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

<script type="text/javascript">
var str = "TEST\'S ";
var finalStr = str.replace("\'","'");
</script>

Thanks for the suggesstion... Its working nice

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.