title: Regular Expression to restrict input field with atmost two decimal places
body: <p>Requirement:</p>
  
  <p>I am trying to restrict the input field to key in only numbers or numbers upto two decimal numbers only. If the user enters more than two decimal places, the input field must display only number upto two decimal places and removing all other. I am using regular expression.</p>
  
  <p>Problem:</p>
  
  <p>When more than two decimal places are entered in input field, all the decimal places are removed and showed. Problem is with regular expression. </p>
  
  <p>Kindly please help me with forming a correct regex.</p>
  
  <p>Code:</p>
  
  <p><a href="http://jsfiddle.net/h6kYh/" rel="nofollow">http://jsfiddle.net/h6kYh/</a></p>
  
  <pre><code>$(document).ready(function() {
  
    $("#AmountField").bind("keyup change", function() {
  
      var value = $(this).val();
  
        var numericReg = /^d+(?:\.\d{0,2})?$/ ;
        if( !numericReg.test(value) )
        {
            value = value.replace(/(?=\d*\.?)(\d{3})/g,"");
            $(this).val(value);
        }
    });
  });
  </code></pre>