Form validation of numeric characters in JavaScript
<p>I would like to perform form validation using JavaScript to check for input field only to contain numeric characters.So far, the validation checks for the field not being empty - which works fine.However, numeric characters validation is not working.I would be grateful for any help.Many thanks.</p>

<pre><code>&lt;script type="text/javascript"&gt;
//form validation
function validateForm()
{
var x=document.forms["cdp_form"]["univer_number"].value
if (x==null || x=="")
  {
  alert("University number (URN) field must be filled in");
  cdp_form.univer_number.focus();
  return false;
  }
else if (is_valid = /^[0-9]+$/.test(x))
    {
    alert("University number (URN) field must have numeric characters");
    cdp_form.univer_number.focus();
    return false;
  }
}
&lt;/script&gt;


&lt;input type ="text" id="univer_number" maxlength="7"    size="25"   name="univer_number" /&gt;
</code></pre>
