Avatar of Mark_Fay
Mark_Fay
Flag for United States of America asked on

Javascript Special Character Replace String

I have an asp page with Javascrippt.  The page uses a thrid party component that does a mouse oever effect which pulls data from my database table.  I am having the problem that special characters are creating an unterminated string error.

I have gotte around the most common one by using the script below to delete out the apostrophes.  I have a new client that needs to see those apostrophes and also any other special character.

function apostoquote()
 {
 var replacewith="";
 var oldstring=FrontPage_Form1.QuestionHelp.value;
 var newstring=oldstring.replace(/'/g,replacewith);
 {
FrontPage_Form1.QuestionHelp.value=newstring
}
}

So I need a script that will
Check the entire FrontPage_Form1.QuestionHelp.value string, find all special characters (!,@,#,$,%,^,&,*,(,),_,+,|,{,},[,], carriage return, tab,',",:,;,?,<,>,.,/) and replace them with code that will work in HTML.

THANKS
ASP

Avatar of undefined
Last Comment
Mark_Fay

8/22/2022 - Mon
HainKurt

use escape js function
or try urlencode functions on server
Mark_Fay

ASKER
Want to use the JS function can you send an example?
ASKER CERTIFIED SOLUTION
HainKurt

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Mark_Fay

ASKER
Take a look you will see.
Your help has saved me hundreds of hours of internet surfing.
fblack61