$("#num").on('paste', function(e,target) {
var pastedText;
if (window.clipboardData && window.clipboardData.getData) {
pastedText = window.clipboardData.getData('Text');
} else {
pastedText = e.originalEvent.clipboardData.getData('Text');
}
var pattern = new RegExp("[^A-Za-z0-9]+$","gm");
pastedText = pastedText.replace(pattern,'');
setTimeout(function() {
$(e.target).attr("value", pastedText);
}, 100);
});