title: Javascript rounding to two decimal places
body: <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
      &lt;title&gt;Round to 2 Decimal Places&lt;/title&gt;
      &lt;script type="text/javascript"
      src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js"&gt;
      &lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          $(function() {
              $('input#txtNum').blur(function() {
                  var amt = parseFloat(this.value);
                  //$(this).val('$' + amt.toFixed(2));
                  $(this).val((Math.round(amt*100))/100).toFixed(2);
              });
  
          });
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      Type a decimal number in the TextBox and hit Tab
      &lt;br /&gt;
      &lt;input id="txtNum" type="text" /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>when i am entering value as 100.2569.The result shows 100.26 but when i am entering 56.999 its showing 57 instead of 57.00 or if i am giving value without decimal its showing without decimals without two appending two zeroes after decimal.</p>