AnsweredAssumed Answered

Custom JavaScript variable declaration fails when the value have special characters

Question asked by akatla on Apr 23, 2015
Latest reply on Apr 28, 2015 by akatla

Hi there,

 

Environment: SharePoint on-premise 2013 and Nintex Forms 2013

 

I have a custom function in which I have a simple variable declaration:

var bulletinTitle = Title;

 

When user inputs the Title value as: 2015 Guest Experience Information" Pack

The page does not load as the JavaScript files to load because of the following error:

 

     SyntaxError: missing ; before statement

 

var bulletinTitle = 2015 Guest Experience Information" Pack;

 

I tried all the options such as:

  • var bulletinTitle = "Title";
  • var bulletinTitle = 'Title';  // The above example works here but fails when user have Single Qoute in the title '
  • var bulletinTitle = fn-Replace(Title, '"', '\"');

 

Does anyone came across this and how did you fix it ?

 

Thanks in advance.

Outcomes