function validate(theform)
{

if(theform.alias.value=="")
{
alert("Please enter a nickname for your recipient.");
theform.alias.focus();
return false;
}

if(theform.alias.value.length > 8)
{
alert("The length of the nickname should not exceed 8 alphanumeric characters.");
theform.alias.focus();
return false;
}

if(theform.sex.selectedIndex ==0)
{
alert("Please select the sex.");
theform.sex.focus();
return false;
}

if(theform.fname.value == "")
{
alert ("Please enter the recipient's first name.");

theform.fname.select();
theform.fname.focus();
return false;
}
else
{
for(var i=0;i<theform.fname.value.length;i++)
{
if(theform.fname.value.charAt(i)<'A' || theform.fname.value.charAt(i)>'Z')
{
if(theform.fname.value.charAt(i)<'a' || theform.fname.value.charAt(i)>'z')
{
if(!((theform.fname.value.charAt(i)=='.') || (theform.fname.value.charAt(i)==' ')))
{
alert("Only alphabets, a space and the character '.' are allowed in the first name field.");
theform.fname.select();
theform.fname.focus();
return false;
}
}
}
}
}


if(theform.lname.value == "")
{
alert ("Please enter the recipient's last name.");

theform.lname.select();
theform.lname.focus();
return false;
}
else
{

for(var i=0;i<theform.lname.value.length;i++)
{
if(theform.lname.value.charAt(i)<'A' || theform.lname.value.charAt(i)>'Z')
{
if(theform.lname.value.charAt(i)<'a' || theform.lname.value.charAt(i)>'z')
{
if(!((theform.lname.value.charAt(i)=='.') || (theform.lname.value.charAt(i)==' ')))
{
alert("Only alphabets, a space and the character '.' are allowed in the middle name field.");
theform.lname.select();
theform.lname.focus();
return false;
}
}
}
}
}

if(theform.acode.value=="")
{
 alert("Please enter the recipient's area code.");
 theform.acode.select();
 theform.acode.focus();
 return false;
}


if(isNaN(theform.acode.value)==true)
{
 alert("Please enter a valid area code.");
 theform.acode.select();
 theform.acode.focus();
 return false;
}

if(theform.telno.value=="")
{
 alert("Please enter the recipient's telephone number.");
 theform.telno.select();
 theform.telno.focus();
 return false;
}
else
 {
  a = theform.telno.value;
  var i=0;
  for(i=0;i<a.length;i++)
  {
   if(a.charAt(i) < '0'|| a.charAt(i) > '9') 
   {
    if(!(a.charAt(i) == ' ' || a.charAt(i) == '(' || a.charAt(i)==')' || a.charAt(i)==',' || a.charAt(i)=='/' || a.charAt(i)=='-' || a.charAt(i)=='+' || a.charAt(i)=='[' || a.charAt(i)==']')) 
    {
     alert("Characters and special symbols are not allowed in the Phone field.");
     theform.telno.select();
     theform.telno.focus();
     return false;
    }
   }
  }
}


if(theform.address.value=="")
{
alert("Please enter the recipient's address.");
theform.address.select();
theform.address.focus();
return false;
}


if(theform.city.selectedIndex==0)
{
 alert("Please select the recipient's city.");
 theform.city.focus();
 return false;
}

if(theform.state.selectedIndex == 0)
{
alert("Please select the recipient's state.");
theform.state.focus();
return false;
}


if(theform.landmark.value=="")
{
alert("Please select a nearby landmark for the address given.");
theform.landmark.focus();
return false;
}

return true;
}


/*function bluremail()
{
document.reg.email.blur();
document.reg.altemail.focus();
}*/


function nickname(theform)
{
if(theform.alias.value=="")
{
alert("Please enter a nickname for your recipient.");
theform.alias.focus();
return false;
}

if(theform.alias.value.length > 8)
{
alert("The length of the nickname should not exceed 8 alphanumeric characters.");
theform.alias.focus();
return false;
}
return true;
}
