//To Check the given control contain only Alpha numeric values

function CheckKeyIsAlphanumerics(oControl)
{
if (/\W/.test(oControl.value))
{
alert("Please enter alphanumerics only");
oControl.value ="";
return false;
}
}

// Another way to validate this is

function CheckKeyIsAlphanumerics(oControl)
{
var regexNum = /\d/;
var regexLetter = /[a-zA-z]/;
if(!regexNum.test(oControl.value) !regexLetter.test(oControl.value))
{
alert('Type alphanumeric character');
return false;
}
}

//To Check the given control contain only Numeric Values

function CheckKeyIsNumerics(oControl)
{
if (/[^0-9]/.test(oControl.value))
{
alert("Please enter only numerics.");
oControl.value ="";
return false;
}
}