blockTabPaste.js

Block a tab from pasting in.

by kaszu

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<body>
  <div>The text below has a tab between the <em>a</em> and the <em>b</em>:</div>
    <pre>a	b</pre>
  <div>Modify the regular expression in the javascript to replace the tab with a single space whenever you paste it into the text box below.</div>
  <div><input type="text"></div>
  <div><a href="#">x</a></div>
</body>

JavaScript

$(document).ready(function() {
          $('input').bind('paste', function() {
            setTimeout(function() {
              var obj = $('input').val();
              var text = obj.replace(/\t/g, ' ');
              $('input').val(text);
            });
          });
        });