JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="pasteIt" placeholder="Paste something here">
JavaScript
$(document).on('paste', '#pasteIt', function(){
alert($("#pasteIt").val());
var withoutSpaces = $("#pasteIt").val();
withoutSpaces = withoutSpaces.replace(/\s+/g, '');
$("#pasteIt").text(withoutSpaces);
});