Monday, October 8, 2007

JavaScript Alpha Numetric field Validation

function Validate_AlphaNumeric()
{
//Author: Surendra Sambana
var strToValidate = '*';
var j=0;

while(j < strToValidate.length)
{
if((97 <= ToAscii(strToValidate.charAt(j)))&&(ToAscii(strToValidate.charAt(j)) <= 122) || (ToAscii(strToValidate.charAt(j)) >= 48)&&(ToAscii(strToValidate.charAt(j)) < 57))
{
// Please change If statement if u want to eliminate else part
}
else
{
alert("please enter a valid Alpha Numeric value");
break;
}
j++;
}
}

No comments: