title: jQuery only allow numbers,letters and hyphens
body: <p>How can I remove everything but numbers,letters and hyphens from a string with jQuery?</p>
  
  <p>I found this code which allows only alphanumerical characters only but I'm not sure how I would go about adding a hyphen.</p>
  
  <pre><code>$('#text').keypress(function (e) {
      var regex = new RegExp("^[a-zA-Z0-9]+$");
      var str = String.fromCharCode(!e.charCode ? e.which : e.charCode);
      if (regex.test(str)) {
          return true;
      }
  
      e.preventDefault();
      return false;
  });
  </code></pre>