title: JavaScript: Mobile number validation with numbers and max length
body: <p>I'm trying to have a JS which has the requirement as below</p>
  
  <p>I have a textbox of type <strong>number</strong> and whenever i typed inside that textbox should <strong>ONLY ALLOW</strong> numbers [0-9] and it should <strong>NOT ALLOW</strong> the length of the numbers entered to  be more than 8 digits. </p>
  
  <p>Eg: </p>
  
  <pre><code>12345678 - Allow
  1234    - Dont Allow
  1234%^  - Dont Allow
  </code></pre>
  
  <p>My Html:</p>
  
  <pre><code>&lt;input type="number" id="txt_number" maxlength="8" onkeypress="return isNumber(event)"&gt;
  </code></pre>
  
  <p>My JS</p>
  
  <pre><code> function isNumber(evt) {
  evt = (evt) ? evt : window.event;
  var charCode = (evt.which) ? evt.which : evt.keyCode;
  if (charCode &gt; 31 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57 ||charCode&gt;=190)) {
      return false;
  }
  return true;
  }
  </code></pre>
  
  <p>Please help me.</p>
  
  <p>Appreciate.
  Thanks</p>