Solved

Replace Smart Quotes with javascript

Posted on 2004-08-09
2
2,045 Views
Last Modified: 2009-02-13
I'm trying to write a validation script that takes the information in the "Description" field and replaces any "smart quotes" with a standard single apostrophe.  The tool is used by those that typically save paragraphs from Microsoft Word and these "funky" apostrophies are causing the application to crash.  Any thoughts?

here's my current code:

strDescription = String( theForm.Description.value )
_re = /’/gi;
strDescription = strDescription.replace( _re, "'" );
0
Comment
Question by:peerlesslv
[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 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 125 total points
ID: 11756523
Hi

For single quotes, have this:

strDescription = String(theForm.Descript.value)
_re = /(?:\u2018|\u2019)/gi;
strDescription = strDescription.replace(_re, "'");

Regards,
Zyloch
0
 

Author Comment

by:peerlesslv
ID: 11756652
Perfect.  Thank you much Zyloch.

0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

689 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