Monday, 2 September 2013

When i input numeric , it also detect it as incorrect format

When i input numeric , it also detect it as incorrect format

function checkAge(form) /* for age validation */
{
var eobj=document.getElementById('ageerror');
var age = form.age.value;
var oR =/[0-9,.]+/;
eobj.innerHTML='';
if (age == '') {
error='Error: Age cannot be blank!';
form.age.focus();
}
else if (!oR.test(age))
{
error='Incorrect format!'
}
if (error)
{
form.age.focus();
eobj.innerHTML=error;
return false;
}
}
var oR =/[0-9,.]+/;
else if (!oR.test(age))
something error at this part?
hopefully someone can help me solve the problem,thx!

No comments:

Post a Comment