Created
January 22, 2015 14:24
-
-
Save davidkryzaniak/9a50437bb7e1ff621448 to your computer and use it in GitHub Desktop.
Paste From Word
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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