title: decimal textbox accepting only positive and negative values
body: <p>I have few textbox like this.</p>
  
  <pre><code>&lt;input type="text" class="tblTxtRanges"  /&gt;
  &lt;input type="text" class="tblTxtRanges"  /&gt;
  </code></pre>
  
  <p>I have to make this textbox accept only decimal values. Both positive and negative numbers. User can type values, copy and paste in the textbox.</p>
  
  <p>I have to replace all other characters other than numbers, one dot, and one minus symbol.
  There is no restriction on decimal places.
  eg: of Valid entries are 
  10
  10.11
  -11
  -11.23655 etc.</p>
  
  <hr>
  
  <h2><strong>What I done so far?</strong></h2>
  
  <pre><code>$(document).on("keypress keyup blur", ".tblTxtRanges", function (event) {
      //this.value = this.value.replace(/[^0-9\.]/g,'');
      $(this).val($(this).val().replace(/[^-?[0-9]+(\.[0-9]+)?]/g, ''));
      if ((event.which != 46 || $(this).val().indexOf('.') != -1) &amp;&amp; (event.which &lt; 48 || event.which &gt; 57) &amp;&amp; (event.which != 45 || $(this).val().indexOf('-') != -1)) {
          event.preventDefault();
      }
  });
  </code></pre>
  
  <p>As this wont solve the problen when user copy and paste a value in textbox, i added a change event function to replace the value to a valid decimal. But this is not replacing the value. (is there any error in regex? the value is same after the replace function)</p>
  
  <pre><code>$(document).on("change", ".tblTxtRanges", function (event) {
      var newVal = $(this).val().replace(/[^-?[0-9]+(\.[0-9]+)?]/g, '');
      $(this).val(newVal);
  });
  </code></pre>
  
  <p>This code is working <strong>but not when copy paste on textbox</strong>. 
  Also we can enter the minus symbol anywher while entering. (ie. like 002-56.36).
  Need a jQuery solution as i am looking for older browser compatibility. </p>
  
  <p>Any better ideas? anything i can change in the regex to replace other characters? </p>