title: Regex to allow hypen & number only
body: <p>I am using the RegEx <code>^[0-9]+$"</code> to allow only digits.
  I want to allow hyphens <code>-</code> &amp; spaces also. </p>
  
  <p>Can any one help me to modify the RegEx to a proper one? </p>
  
  <p>I was using following JS code to achieve the same, but in this way if the user is copying &amp; pasting the text then the key press is not getting accounted.</p>
  
  <pre><code>//Allowed characters are : 8 = Back space,
  //9 = Horizontal tab, 27 = esc, 127 = Delete,
  //13 = Enter digits = 48 to 57, 45 = hypen
  
  $('#PostalCode').keypress(function (e) {
      var key = (e.keyCode ? e.keyCode : e.which);
      return (key == 8 || key == 9 || key == 127 || key == 27 || key == 13 || key == 45 || (key &gt;= 48 &amp;&amp; key &lt;= 57));
  });
  </code></pre>