Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Javascript Special Character Replace String

Posted on 2010-09-07
4
Medium Priority
?
452 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 59

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 59

Accepted Solution

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

719 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