title: JavaScript Regex for positive numbers with one dot and 2 decimal
body: <p>I am quite new to regex and I have a problem with regex expression.</p>
  
  <p>I want to only allow a user to enter positive numbers, with or without one dot and up to 2 decimals (can be only 1 decimal also). Upon user typing the text inside the textbox, and if they type the wrong format, I want to remove the other characters and replace the value with the correct format.</p>
  
  <p>Valid examples:</p>
  
  <pre><code>123.12
  2
  56754
  92929292929292.12
  0.21
  3.1
  .90
  </code></pre>
  
  <p>Invalid examples:</p>
  
  <pre><code>12.1232
  2.23332
  e666.76
  -1.23
  -54.3242
  3.98A
  56B
  BBB.12C
  14.23.56
  1..45
  </code></pre>
  
  <p>Currently I found one solution using the following regex : </p>
  
  <pre><code>$("#SomeElement").keyup(function () {
     this.value = this.value.replace(/(\.\d\d)\d+|([\d.]*)[^\d.]/, '$1$2')
  });
  </code></pre>
  
  <p>There are two problems with that</p>
  
  <ol>
  <li>It allows me to enter multiple dots. (e.g 123.89.80)</li>
  <li>Even though if I type like letter "a" once, it filters but if I hold down the letter "a" in keyboard, it still allows to enter (e.g. AAAAAAAAA12), maybe is it because of "keyup" event?</li>
  </ol>
  
  <p>Thank you in advance.</p>