How to block special characters from a "paste"?

1

I have the following problem, there is a validation being done this way:

$(document).ready(function(){
  $(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);
   });
});

When you paste some text with special characters the function of a replace in the special characters by empty . Is there any way to block special paste characters without using replace ?

My biggest problem is that the user can see the characters inside the input before they are replaced, the validation is ok, however I am looking for some other way so that the user does not "see" the replace happening. >     

asked by anonymous 21.08.2017 / 22:26

0 answers