What is incorrect in this function ?

sc203718

28-01-2019

I have this error:

TypeError: s.replace is not a function

68:Doc:Init

This is the code that generates the error:

function EL(s)

{

var sir = "";

sir = s.replace(/[&]/g,"&amp;");                            <<<---------------------- this is the error line

sir = sir.replace(/["]/g,"&quot;");

sir = sir.replace(/[“]/g,"&quot;");

sir = sir.replace(/[”]/g,"&quot;");

sir = sir.replace(/[']/g,"&apos;");

  

return sir;

}

I am a newbie in javascript and adobe livecycle designer...what is causing the error ? What should i do

Accepted Solutions (1)

Accepted Solutions (1)

Answers (5)

Answers (5)

Magus069

MVP

28-01-2019

This seem to be working fine for me...

ensure that this.rawValue is in fact returning the value desired...

use app.alert(this.rawValue);

Mayank_Gandhi

Employee

28-01-2019

Please try updating script to below:

var sir = "";

sir=this.rawValue;

sir = sir.replace(/[&]/g,"&amp;");                          

sir = sir.replace(/["]/g,"&quot;");

sir = sir.replace(/[“]/g,"&quot;");

sir = sir.replace(/[”]/g,"&quot;");

sir = sir.replace(/[']/g,"&apos;");

Thanks,

Mayank