JSFiddle - React, Tailwind, and code Playground
HTML
<a href="#" id="on"> Use the .on() event to get the pasted text </a>, or </br>
<a href="#" id="bind"> use the .bind() event to get the pasted text </a>
<br/>
<textarea id="post">
</textarea>
JavaScript
$('#on').click(function(){ useOn('post'); });
$('#bind').click(function(){ useBind('post'); });
function useBind(obj){
$('#'+obj).off();
$('#'+obj).bind('paste', function(){
setTimeout(function(){
var $ptext = $('textarea#post').val();
var regexText = /^http:\/\/www$/;
if(regexText.test($ptext))
{
console.log('if = true using the .bind() event');
}
else
{
console.log('if = false using the .bind() event');
}
}, 100);
});
}
function useOn(obj){
$('#'+obj).unbind('paste');
$('#'+obj).on('paste' , function(){
setTimeout(function(){
var $ptext = $('textarea#post').val();
var regexText = /^http:\/\/www$/;
if(regexText.test($ptext))
{
console.log('if = true using the .on() event');
}
else
{
console.log('if = false using the .on() event');
}
}, 100);
});
}