title: Javascript - validation, numbers only
body: <p>I'm trying to get my login form to only validate if only numbers were inputted. I can it to work if the input is only digits, but when i type any characters after a number, it will still validate etc. 12akf will work. 1am will work. How can i get past this?</p>
  
  <p>Part of the Login</p>
  
  <pre><code>&lt;form name="myForm"&gt;
      &lt;label for="firstname"&gt;Age: &lt;/label&gt;
      &lt;input name="num" type="text" id="username" size="1"&gt;
      &lt;input type="submit" value="Login" onclick="return validateForm()"&gt;
  
  function validateForm()
  {
  
      var z = document.forms["myForm"]["num"].value;
      if(!z.match(/^\d+/))
          {
          alert("Please only enter numeric characters only for your Age! (Allowed input:0-9)")
          }
  }
  </code></pre>