title: Best Way to Remove Unwanted Characters
body: <p>I have an HTML input that I want to sanitize. I want users to enter everything except some characters. I don't know what those characters are, but users somehow enter them by copying and pasting. Sublime Text shows them as STX, SOH and so on. I don't know if you can see them, but here they are:"      
    ". 
  I don't want to list every character that I accept, nor I can list these STX, SOH characters. I can't use A-Za-z, because I also want users to enter characters like 'ç'. </p>
  
  <p>How can I achieve this easily? </p>
  
  <p>Here's a part of the -unfinished- code that I found on here: </p>
  
  <pre><code>function validate(evt) {
    var theEvent = evt || window.event;
    var key = theEvent.keyCode || theEvent.which;
    key = String.fromCharCode( key );
    // var regex = /[0-9]|\./;
    var regex = /[a-zA-Z0-9\!\'\+\-\&amp;\\\/\(\)\?\@\#\$\%\^\*\_\|]+/;
    if( !regex.test(key) ) {
      theEvent.returnValue = false;
          theEvent.preventDefault();
    }
  }
  </code></pre>
  
  <p>Thank you very much in advance</p>