function validateForm()
{
   var illegalChars = /[\W_]/; // allow only letters and numbers
    dateVar = new Date()
	 year=(dateVar.getYear());

if (document.regform.relationship.value=="")
     {
		  alert("Select Relationship")
		  document.regform.relationship.focus();
		  return false;
	 }
	/*if (document.regform.login.value=="")
	 {
		  alert("Enter login name")
		  document.regform.login.focus();
		  return false; 
	 }*/
	/*if (firstchar(document.regform.login.value))
	 {
		  alert("First charcter must be alphabet")
		  document.regform.login.focus();
		  return false; 
	 }*/ 
	  
	 if (!validateEmail(document.regform.email))
	   {
			return false;		   
	   }
	   if (firstchar(document.regform.email.value))
	 {
		  alert("First charcter must be alphabet for email")
		  document.regform.email.focus();
		  return false; 
	 } 
	  if (!validateEmail(document.regform.retypeemail))
	   {
			return false;		   
	   }
	  
	   if(document.regform.retypeemail.value!=document.regform.email.value)
	   {
		   alert("Emails doesnot match..Enter again");
		   return false;
	   }
	  
	  if (document.regform.password1.value=="") 
	  {
	  	alert("Enter Password")
	  	document.regform.password1.focus();
	  	return false;
	  }
	  if (document.regform.password1.value.length < 4) 
	  {
	  	alert("password length should be more than 4 characters")
	  	document.regform.password1.focus();
	  	return false;
	  }
	  if (illegalChars.test(document.regform.password1.value)) {
      error = "The password contains illegal characters.\n";
      alert (error);
      return false;
    } 
	  
	  if (document.regform.password2.value=="") 
	  {
	  	alert("Enter confirm Password")
	  	document.regform.password2.focus();
	  	return false;
	  }
	  if (document.regform.password1.value!=document.regform.password2.value)
	  {
	    alert ("Password's don't match..Enter again")
	    return false;
	  }  
	  if (document.regform.gender[0].checked==false & document.regform.gender[1].checked==false)
	  {
	  	alert("Please check gender")
	  	return false;
	  }
	  if ((document.regform.day.value=="")) 
	  {
	    alert ("Select Day");
	    document.regform.day.focus();
	    return false;
	  }  
	  if ((document.regform.month.value==""))
	  {
	    alert ("Select Month");
	    document.regform.month.focus();
	    return false;
	  }
	  if ((document.regform.year.value==""))
	  {
	    alert ("Select Year");
	    document.regform.year.focus();
	    return false;
	  }
	 /* age=year+1900-document.regform.year.value
	  if (age>50 || age<18)
	  {
		  	alert(age);
	  	 alert ("Invalid age");
	    document.regform.year.focus();
	    return false;
	  }*/
	  if ((document.regform.community.value==""))
	  {
	    alert ("Select Community");
	    document.regform.community.focus();
	    return false;
	  }  
	  
	  if ((document.regform.country.value==""))
	  {
	    alert ("Select Country");
	    document.regform.country.focus();
	    return false;
	  }
	 return true;
}
function validateEmail(email) {

	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	if (!re_mail.test(email.value)) {
		alert("Enter Valid Email");
		email.focus();
		email.select();
		return false;
	}

	return true;
}
function firstchar(str1)
{
	value1=(str1.charCodeAt(0))
	if ((value1>=65 && value1<90) ||(value1>=97 && value1<122))
	return 0;
	else
	return 1;
}