2
I have the following problem:
Some people in my work copy texts of some words and paste in forms which I do (inside the GED), but sometimes in this copy and paste it take with the text some invalid characters, for example those quotation marks: "
I had the idea to capture the necklace, treat it and then paste the treaty text. Follows the code:
$(document).ready(function(){
var clipboardData, pastedData;
$(":input").on("paste", function (e) {
e.preventDefault();
clipboardData = e.clipboardData || window.clipboardData;
pastedData = clipboardData.getData('text');
// smart single quotes and apostrophe
pastedData = pastedData.replace(/[\u2018\u2019\u201A]/g, "\'");
// smart double quotes
pastedData = pastedData.replace(/[\u201C\u201D\u201E]/g, "\"");
// ellipsis
pastedData = pastedData.replace(/\u2026/g, "...");
// dashes
pastedData = pastedData.replace(/[\u2013\u2014]/g, "-");
this.value += pastedData;
});
});
I used at the time of pasting after treating the "value +=" however in this case, whenever someone put the pointer in the middle of a text already typed, it will ignore where the pointer is and will "paste" the contents of the treatise at the end of the text. How can I put the contents of the treated Paste where the pointer is?
Oops, it worked here! VLW
– CarlosM