Solved

Javascript Special Character Replace String

Posted on 2010-09-07
4
449 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:Mark_Fay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 53

Expert Comment

by:Huseyin KAHRAMAN
ID: 33620336
use escape js function
or try urlencode functions on server
0
 

Author Comment

by:Mark_Fay
ID: 33620344
Want to use the JS function can you send an example?
0
 
LVL 53

Accepted Solution

by:
Huseyin KAHRAMAN earned 500 total points
ID: 33623487
<script>
var val = "characters (!,@,#,$,%,^,&,*,(,),_,+,|,{,},[,],";
alert(val);
alert(escape(val));
</script>
0
 

Author Closing Comment

by:Mark_Fay
ID: 34072853
Take a look you will see.
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Index on a Table 6 38
Multiflying 2 Input Text On a Table 7 36
Set time on Session (ASP) 14 38
ASP Classic - Read XML File inner content 10 73
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question