function validate()
{

 if (  isName()  && isFullName())
   {
      document.frmregister.submit()
   }


}

function isName() 
{
  var str = document.frmregister.username.value;
  if (str == "")
  {
    alert("\nThe Login Name field is blank .\n\nPlease re-enter your Login Name.")
    document.frmregister.username.focus();
    return false;
  }
  if((str.substring(0,1)<"a" || str.substring(0,1)>"z") && (str.substring(0,1)<"A" || str.substring(0,1)>"Z"))
   {
     alert("The Login Name should begin with an alphabetic character.");
     return false;
   }
   for (var i = 1; i < str.length; i++) 
   {
     var ch = str.substring(i, i + 1);
     if ( ((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) && (ch < "0" || "9" < ch) && (ch != '_')) 
     {
      alert("\nThe Login Name field  accepts letters,numbers & underscore.\n\nPlease re-enter your Login Name.");
      document.frmregister.username.select();
      document.frmregister.username.focus();
      return false;
     }
   }
   return true;
}


function isFullName()
{
	b=0
   var name1 = document.frmregister.fname.value;
   var name2 = document.frmregister.lname.value;
   var dob1 = document.frmregister.month.value  
   var dob2 = document.frmregister.day.value  
   var dob3 = document.frmregister.year.value  
   var email1 = document.frmregister.email.value;
   var city1 = document.frmregister.city.value;
   var state1 = document.frmregister.state.value;
   var zip1 = document.frmregister.zip.value;
   var address1 = document.frmregister.address.value;
   var country1 = document.frmregister.country.value;
   var cnumber1 = document.frmregister.cnumber.value;
	
   if(name1 == "") 
   {
     alert("Please enter your first name.");
     document.frmregister.fname.focus();     
     return false;
   }
   
   if(isNotAlphabets(name1))
   {
     alert("The first name field contains invalid characters or spaces.\n Please re-enter your first name again.");
   return false;
   } 
 

   if(name2 == "")
   {
     alert("Please enter your last name.");
     document.frmregister.lname.focus();
     return false;
   }
   
     if(isNotAlphabets(name2))
  {
    alert("The last name field contains invalid characters or spaces.\n Please re-enter your last name again.");
    return false;
  }
   
   if ( dob1 == 0 )
  {
     alert("Please select your Date of Birth.");
     document.frmregister.month.focus()
     return false;
  }
  
  if ( dob2 == 0 )
  {
     alert("Please select your Date of Birth.");
     document.frmregister.day.focus()
     return false;
  }

  if ( dob3 == 0 )
  {
     alert("Please select your Date of Birth.");
     document.frmregister.year.focus()
     return false;
  }
  
    if (!(document.frmregister.gender[0].checked || document.frmregister.gender[1].checked))
  {
     alert("Please select your Gender")
     document.frmregister.gender[0].focus()
     return false;
  }
  
if(cnumber1 == "")
   {
     alert("Please enter your Contact Number.");
     document.frmregister.cnumber.focus();
     return false;
   }
   
   
   if(email1 == "")
   { 
     alert("Please enter your Email Address.");
     document.frmregister.email.focus();
     return false;
   }
	split=email1.split("")
     for(i=0;i<split.length-1;i++)
     {if(split[i]=="@")
     {b=1}
     }
     if(b==0)
     {alert("Please enter proper Email Address");
     document.frmregister.email.focus();
     return false;
     }
	
	 
if(city1 == "")
   {
     alert("Please enter your City Name.");
     document.frmregister.city.focus();
     return false;
   }
   
  if(zip1 == "")
   {
     alert("Please enter your Zip code.");
     document.frmregister.zip.focus();
     return false;
   } 
if(document.frmregister.state.options[0].selected)
   {
     alert("Please enter your State Name.");
     document.frmregister.state.focus();
     return false;
   }

if(country1 == "")
   {
     alert("Please enter your Country Name.");
     document.frmregister.country.focus();
     return false;
   }
   
   
  
    
   return true;

}

function isNotAlphabets(str)
{
  for (var i = 0; i < str.length; i++)
  {
    var ch = str.substring(i, i + 1);
    if((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) 
    {
      return true;
    }
  }
  return false;
}




