title: JQuery validation code will not allow deletion of entered text
body: <p>I borrowed a bit of code from this question (see reply 4):</p>
  
  <p><a href="https://stackoverflow.com/questions/895659/how-do-i-block-or-restrict-special-characters-from-input-fields-with-jquery">how do i block or restrict special characters from input fields with jquery?</a></p>
  
  <p>However, upon using the code, it appears, that although it does the validation as you type neatly, it does not allow you to edit anything you have entered.</p>
  
  <pre><code>$('input').bind('keypress', function (event) {
  var regex = new RegExp("^[a-zA-Z0-9]+$");
  var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
  if (!regex.test(key)) {
     event.preventDefault();
     return false;
  }});
  </code></pre>
  
  <p>I am a bit confused, I have tried to adjust it by changing the keypress to keyup but this just stops the validation from working. Any pointers would be graciously accepted.</p>