Replacing MS Word

Replacing Microsoft Word Special Characters

Jon Volks
Written By | @webproninja

One of the biggest complaints I get from my content users is web users filling out a form and they copy/paste from Microsoft Word. All the quotes and apostrophes show up as curly ones and depending on character encoding, do not show up (or at least show up as unrecognizable such as a square). Microsoft Windows uses Windows-1252 character encoding set which is not represented in ASCII or ISO-8859-1. To help out my content users, I created a little simple jQuery function to replace these special characters when they are pasted in a text field or textarea.

function replaceSpecialWordCharacters(form_input) {
var input_value = form_input.val();
input_value = input_value.replace(/[\u2018|\u2019|\u201A]/g, "'");
input_value = input_value.replace(/[\u201C|\u201D|\u201E]/g, '"');
input_value = input_value.replace(/\u2026/g, "...");
input_value = input_value.replace(/[\u2013|\u2014]/g, "-");

$("form input").blur(function() {

$("form textarea").blur(function() {

About The Author

Jonathan Volks is currently a Web Programmer at Skidmore College in Upstate New York. He enjoys everything about the Internet; from Search Engine Optimization to Web Programming. His hobbies include landscape photography and hiking the Adirondacks.

Leave a Reply

Your email address will not be published. Required fields are marked *