Solved

Javascript Special Character Replace String

Posted on 2010-09-07
4
451 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 56

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 56

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

617 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