title: JS only alpha numeric and spaces on keyup
body: <p>I want to limit input to letters numbers and spaces.</p>
  
  <p>And I want it to run on keyup so the user sees other characters being rejected. In other words, I don't want the illegal characters to remain in the field and only get deleted after submission.</p>
  
  <p>I tried this...</p>
  
  <pre><code>$('#custName').keyup(function() {
      $(this).val($(this).val().match(/^[\w\s]+$/));
  });
  </code></pre>
  
  <p><a href="http://jsfiddle.net/nSFBk/160/" rel="nofollow">Fiddle</a></p>
  
  <p>But as soon as an illegal character is entered, the whole string is deleted.</p>
  
  <p>How can I prevent illegal character as it is entered, while keeping the legal ones? </p>