DEV Community

Joe Pool
Joe Pool

Posted on

How do I remove a TAB from text that is pasted in from the clipboard?

I think I am failing on my regular expression, the best I can tell.

    $(document).ready(function() {
      $('input').bind('paste', function() {
        setTimeout(function() {
          var obj = ('input').val();
          var text = obj.replace('^[a-zA-Z0-9\\-\\s]+$', ' ');
          $('input').val(text);
        });
      });
    });
Enter fullscreen mode Exit fullscreen mode

I have made a fiddle here:

https://jsfiddle.net/jp2code/5enmojb2/20/

Top comments (0)