title: Validate input value to allow only integer and decimal value using Js regex
body: <p>I am new to javascript. I want to validate input box value it should allow integer and decimal value (no alphabets), no limit for integer value but for decimal value it should accept only two digit after decimal point.
  <a href="https://jsfiddle.net/pnd6yvbj/" rel="nofollow noreferrer">https://jsfiddle.net/pnd6yvbj/</a>
  Example:</p>
  <p>Allowed values in and decimal</p>
  <pre><code>1.1
  1.12
  233
  </code></pre>
  <p>Not allowed more than two decimal point</p>
  <pre><code>1.121
  </code></pre>
  <p>What I tried:</p>
  <pre><code>&lt;input type=&quot;text&quot; id=&quot;txt&quot; value=&quot;&quot; onkeyup = &quot;check_val($(this).val())&quot;/&gt;
  
  &lt;script&gt;
  function check_val(val) {
        var val = val.replace(^[1-9]\d*(\.\d+)?$,&quot;&quot;);
         $(&quot;#txt&quot;).val(val.split('  ').join(' '));
      }
  &lt;/script&gt;
  </code></pre>