Skip to content

Instantly share code, notes, and snippets.

@davidkryzaniak
Created January 22, 2015 14:24
Show Gist options
  • Save davidkryzaniak/9a50437bb7e1ff621448 to your computer and use it in GitHub Desktop.
Save davidkryzaniak/9a50437bb7e1ff621448 to your computer and use it in GitHub Desktop.
Paste From Word
$(function(){
//bind on paste action
$('input,textarea').on('paste', function () {
var element = this; //grab the element that was pasted into
setTimeout(function () {
var text = $(element).val();
text = text
.replace(/\u2013|\u2014/g, "-") //Fix dashes
.replace(/[\u2018\u2019]/g, "'") //Fix single quotes
.replace(/[\u201C\u201D]/g, '"'); //Fix double quotes
$(element).val(text);
}, 100);
});//end on.paste
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment