title: html input validation that works when using paste
body: <p>I am using the following code for my validation that only allows letters and numbers and a few allowed characters.</p>
  
  <pre><code>$('input').bind('keypress', function (event) {
      var regex = new RegExp("^[a-zA-Z0-9%()#@-_&amp; ]+$");
      var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
      if (!regex.test(key)) {
         event.preventDefault();
         return false;
      }
  });
  </code></pre>
  
  <p>The only problem I am having is that if you copy and paste any un allowed characters then this doesn't prevent it. I know I have seen this done somewhere where it prevents the characters being pasted. Any thoughts?</p>