I was trying to do a validation but with .on ('input') it works better than .on ('paste') a timeout for it to work), can someone explain the difference between the two? Here is my code to illustrate the question:
paste
$(this).on("paste", "#email", function(event) {
var $obj = $(this);
setTimeout(function() {
var str = $obj.val();
$obj.val(str.replace(/[^a-za-uA-ZA-U0-9_@\.\'\b\t]/g, ''));
}, 2);
});
input
$(this).on("input", "#email", function(event) {
var $obj = $(this);
var str = $obj.val();
$obj.val(str.replace(/[^a-za-uA-ZA-U0-9_@\.\'\b\t]/g, ''));
});
change
$(this).on("change", "#email", function(event) {
var $obj = $(this);
var str = $obj.val();
$obj.val(str.replace(/[^a-za-uA-ZA-U0-9_@\.\'\b\t]/g, ''));
});