Solved

Javascript Special Character Replace String

Posted on 2010-09-07
4
442 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
  • 2
  • 2
4 Comments
 
LVL 51

Expert Comment

by:HainKurt
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 51

Accepted Solution

by:
HainKurt 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iis reverse proxy virtual directory 8 134
Using Currency Layer API within ASP 10 81
two-way Authentication ASP 3 80
Classic ASP application Will support SQL 2014 5 73
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now