jQuery in Action, 2nd edition*
The moose likes HTML, CSS and JavaScript and the fly likes Java Script - Problem When data has apostrophe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Java Script - Problem When data has apostrophe" Watch "Java Script - Problem When data has apostrophe" New topic

Java Script - Problem When data has apostrophe

Madhumathy Viswanathan

Joined: Jun 01, 2005
Posts: 6
There is a link which calls the javascript function. This link passes a String (which has an apostrophe)as an input to the script. At this point, the javascript function is not called.If the input String to javascript function does not have apostrophe , then the method is called successfully!!

Kindly help me out how to handle inputs with apostrophe

Thanks in advance

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
It needs to be escaped "\" so it does not affect the string.

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41034
Have you tried escaping the apostrophes, writing 'abc\"def" instead of 'abc"def'? It would be a good idea to do that for single quotes as well.

Ping & DNS - my free Android networking tools app
It is sorta covered in the JavaRanch Style Guide.
subject: Java Script - Problem When data has apostrophe
Similar Threads
Getting a String from a Javascript function call
using replaceAll() function with jstl
retrieve value at servlet from javascript.
javascript: referrer unknown
need help with jquery autocomplete