title: how to make a text field to accept only numbers, and two decimal places
body: <p>I need to make a text field accept only numbers and decimal point, and default to two decimal places.
  I got this code from a search here. It works for accepting only numbers.
  I need to make it accept decimal point, and default to two decimal places.</p>
  
  <pre><code>&lt;input type="text" onkeypress="return event.charCode === 0 || /\d/.test(String.fromCharCode(event.charCode));" /&gt;
  </code></pre>
  
  <p>Thanks</p>