+ Start a Discussion
aveforstudy1.3196212890020557Eaveforstudy1.3196212890020557E 

Apostrophe issue

Hi,

I am facing a apostrophe issue in my Visual force page.

I have a custom page which has a Account field which is a lookup, when the user clicks on the magnifying glass my custom Visual force page is opened. Everything works fine, except the time when a particular account has a name with an apostrophe.

I have written a javascript function that closes the popup as soon as the account is selected, the selected accounts name gets added in the text field on my main page.But when an apostrope is found the javascript function does not get callled at all.I have tried many approaches but did not get to a solution.

If anyone has come accross this issue then please let me know what needs to be done.

Thanks in advance!

 

Best Answer chosen by Admin (Salesforce Developers) 
wt35wt35

have you tried the JSENCODE function?

 

JSENCODEEncodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (\), before unsafe JavaScript characters, such as the apostrophe (').{!JSENCODE(text)}and replace text with the merge field or text string that contains the unsafe JavaScript characters.

All Answers

wt35wt35

have you tried the JSENCODE function?

 

JSENCODEEncodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (\), before unsafe JavaScript characters, such as the apostrophe (').{!JSENCODE(text)}and replace text with the merge field or text string that contains the unsafe JavaScript characters.
This was selected as the best answer
aveforstudy1.3196212890020557Eaveforstudy1.3196212890020557E

Yes i used this function and it worked.

Thanks!!!