Allow only numbers and special character(-) to be typed in a textbox : <p>I need to Allow only numbers and special character minus "-" to be typed in a textbox, plz help me i already have a number restriction, but wanna minus sign too.</p>

<p>thanks in advance</p>

<pre><code>&lt;script&gt;
function isNumber(evt) {
    evt = (evt) ? evt : window.event;
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode &gt; 31 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57)) {
        return false;
    }
    return true;
}
&lt;/script&gt;


&lt;input type="text" class="textfield" value="" id="extra7" name="extra7" onkeypress="return isNumber(event)" /&gt;
</code></pre>
