?
Solved

Replace Smart Quotes with javascript

Posted on 2004-08-09
2
Medium Priority
?
2,053 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
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…
Suggested Courses

777 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