javascript validation for allow -1 and all positive numbers in text box
<p>I am trying to validate a text box to allow all positive numbers including -1 in it.</p>

<p>i tried this, which will work for allowing only positive numbers
<code></p>

<pre><code>  function allownumbers(e, txtBox) {
        var key;

        key = (e.keyCode) ? e.keyCode : e.charCode;
        if (e.charCode == 0) {
            return true;
        }
        if ((key &lt; 48 || key &gt; 57) &amp;&amp; (key != 46) &amp;&amp; (key != 44)) {               
            return false;                
        }
        if (key == 46) {
            if ((txtBox.value).indexOf('.') != -1) {
                return false;
            }
        }
        if (key == 44) {
            if ((txtBox.value).indexOf(',') != -1) {
                return false;
            }
        }
        return true;
    }
</code></pre>

<p></code></p>

<p>But how to allow  -1(only) with all positive numbers
Thanks in advance</p>
