Solved

Replace Smart Quotes with javascript

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now