title: Count the number of digits before and after decimal places using Javascript
body: <p>I have a requirement where I should allow a maximum of 14 digits before decimal place and a maximum of 4 digits after decimal place.</p>
  <p>Is there a way that I can let the user know if he is entering 222222222222222.222 -- 15 digits before decimal is invalid once he is out of that textbox using Javascript.</p>
  <p>I tried this but it did not help me:</p>
  <pre><code>  MynewTextBox.Attributes.Add(&quot;onkeyup&quot;, &quot;javascript:this.value=Comma(this.value);&quot;);
  
  function Comma( Num ) {
  
    var period = Num.indexOf('.'); 
     if ( Num.length &gt; (period + 4)) 
     alert(&quot;too many after decimal point&quot;);
     if ( period != -1 ) 
     {
        Num += '00000'; 
        Num = Num.substr( 0, (period + 4));
     } 
  </code></pre>
  <p>Also, the above function is giving me the error:</p>
  <blockquote>
  <p>Object Expected.</p>
  </blockquote>
  <p>Can anyone help me with this.</p>