Solved

Replace Smart Quotes with javascript

Posted on 2004-08-09
2
2,038 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

785 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