Input only with correct numeric
<p>i wanted to ask how i can combine my regex with the if( ( !regex.test( sybol.... condition, if there is a possibility,  and also, how I can shorten my code? without loosing good code view. <strong>Also, dash can be only in first place and only one in input, and the same with dot.</strong></p>

<pre><code>$( this ).bind( 'keypress', function( e ){

    var code = e.keyCode || e.which;
    var symbol = String.fromCharCode( code );
    var regex = /[-0-9]|[\b]/;
    var currVal = $( this ).val();
    var insideInput = currVal.indexOf( '-' );

    if( ( !regex.test( symbol ) &amp;&amp; code != 37 &amp;&amp; code != 39 &amp;&amp; code != 46 ) ||
 ( code == 45 &amp;&amp; insideInput == 0 ) || ( currVal.length != 0 &amp;&amp; code == 45 ) ) {

        e.preventDefault();
    }

});
</code></pre>
