Possible Duplicate:
Validate numbers in JavaScript - IsNumeric()
Hi I am trying to validate a field using javascript to ensure that the field is not empty AND only contains numbers
I am using document.getElementById to get the value of the field, then using this function to validate it:
function isNumeric(elem, message, messsage2)
{
if(isNaN(elem))
{
alert(message2);
return false;
}
else if (elem == null || elem =="")
{
alert(message);
return false;
}
return true;
}
However this function still allows me to enter letters as where there should be numbers