Javascript: Validate a field: Not empty & only contains numbers
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/18082/validate-numbers-in-javascript-isnumeric">Validate numbers in JavaScript - IsNumeric()</a>  </p>
</blockquote>



<p>Hi I am trying to validate a field using javascript to ensure that the field is not empty AND only contains numbers</p>

<p>I am using document.getElementById to get the value of the field, then using this function to validate it:</p>

<pre><code>function isNumeric(elem, message, messsage2)
{
   if(isNaN(elem))
   { 
    alert(message2); 
    return false; 
   }
   else if (elem == null || elem =="")
   {
    alert(message);
    return false;
   }
return true;
}
</code></pre>

<p>However this function still allows me to enter letters as where there should be numbers</p>
