function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Bikram K BhuyanBikram K Bhuyan 

JSENCODE is not working when used with global variable like ($Label) in javascript

Hello Guys,

In our application we are defining custom lebels and we are trying to access the value in javascript section of the visualforce page. But looks like JSENCODE function is not encoding the characters as expected.

The custom lebel name is "END_OF_TERM" and we have defined the label text as "End' of Term" for testing purpose.

The javascript code is like this. var endOfTerm = '{!JSENCODE($Label.END_OF_TERM)}';
After rendering the value we see is as -> 'End' of Term'. Which shows that the single quote inside the text is not encoded. We tried with other characters like double quote but have the same result.

Could you please suggest what we are doing wrong. Any pointer to solve the issue is really appreciated.

Thanks,
Bikram.