title: Input text field that only accepts numbers AND the dash character
body: <p>I'm using the commonly used Javascript function to allow only numbers to be inputted into a text field:</p>
  
  <pre><code>function isNumberKey(evt)
  {
    var charCode = (evt.which) ? evt.which : event.keyCode;
    if (charCode != 46 &amp;&amp; charCode &gt; 31
      &amp;&amp; (charCode &lt; 48 || charCode &gt; 57))
       return false;
  
    return true;
  }
  </code></pre>
  
  <p>I call this onkeypress and it prevents anything but numbers to display. I'm trying to alter it so it will allow me to also put dashes (-) into the text field. The dash keycode is 189 so I tried this:</p>
  
  <pre><code>function isNumberKey(evt)
  {
    var charCode = (evt.which) ? evt.which : event.keyCode;
    if (charCode != 46 &amp;&amp; charCode != 189 &amp;&amp; charCode &gt; 31
      &amp;&amp; (charCode &lt; 48 || charCode &gt; 57))
       return false;
  
    return true;
  }
  </code></pre>
  
  <p>Thinking that the conditional statement would then accept the dash character but that didn't seem to work. Any ideas on why this would be? Thanks for your help!</p>