Adsense
Popular Posts
- MySQL workbench -"Could not decrypt password cache"
- mod_auth_cas.so error: undefined symbol: SSL_connect
- JavaScript, remove trailing insignificant zeros after toFixed function
- Set Windows path command line
- JavaScript Arrays and Associate Arrays
- Design date and signature box in Latex
- Install APXS in Redhat Linux
- super(props) in React
- jQuery, toggle the display
- PHP function for input sanitizing
Showing posts with label paste. Show all posts
Showing posts with label paste. Show all posts
Friday, November 23, 2018
JS/JQuery: paste the plain text only
When I copy the Word document to the text box,
in background a lot html codes and strange characters from Word
are saved.
Below is the JS/JQuery code to paste the plain text ( I have a text box with class comment):
function clickcomments($td){
$td.find('.comment').on('paste', function(event){
event.preventDefault();
var text = (event.originalEvent || event).clipboardData.getData('text/plain') || prompt('Paste something..');
window.document.execCommand('insertText', false, text);
$(this).html($(this).html().replace(/<div>/g, '<br>').replace(/<\/div>/g, '<br>'));
});
}
Subscribe to:
Posts (Atom)