function chkname()
{
 var ch=0;
 name=new String();
 name=document.Form1.Name.value;

 if (name.length==0)
  alert ("Enter your Name")
 else
 {
  u=0;
  for (i=0;i<name.length;i++)
  {
   if ((name.charCodeAt(i) >= 64 && name.charCodeAt(i) <= 90)||(name.charCodeAt(i) >= 97 && name.charCodeAt(i) <= 122)||(name.charCodeAt(i)==46)||(name.charCodeAt(i)==32))
   {
   }
   else
   {
    u=u+1;
   }
  }
  if (u>0)
  {
   alert ("Invalid Name");
  }
  else
  {
   chkSurname()
  }
 } 
}

function chkSurname()
{
 var ch=0;
 surname=new String();
 surname=document.Form1.Surname.value;
 
 if (surname.length==0)
  alert ("Enter your Surname")
 else
 {
  u=0;
  for (i=0;i<surname.length;i++)
  {
   if ((surname.charCodeAt(i) >= 64 && surname.charCodeAt(i) <= 90)||(surname.charCodeAt(i) >= 97 && surname.charCodeAt(i) <= 122)||(surname.charCodeAt(i)==46)||(surname.charCodeAt(i)==32))
   {
   }
   else
   {
    u=u+1;
   }
  }
  if (u>0)
  {
   alert ("Invalid Surname");
  }
  else
  {
   chkemail()
  }
 } 
}

function chkcomments()
{
 com=new String();
 com=document.Form1.Comments.value;
 
 if(com.length<1){
   alert("Please enter your Comments.");
   }
 else
 	{
		document.Form1.submit();
 	}	
 }

function chkemail()
{
 mail=new String();
 mail=document.Form1.E_Mail.value
 
 if (mail.length<1)
     alert ("Enter your E Mail")
 else
  {
   at_pos=mail.indexOf("@")
   dot_pos=mail.indexOf(".")
   if(at_pos<1 || dot_pos<1)
   alert("Missing '@' and '.' in email address.")
   
 else
  {
   u=0;
   p=0;
   for(var i=0;i<mail.length;i++)
   {
    if ((mail.charCodeAt(i) >= 64 && mail.charCodeAt(i) <= 90)||(mail.charCodeAt(i) >= 97 && mail.charCodeAt(i) <= 122)||(mail.charCodeAt(i) >= 48 && mail.charCodeAt(i) <= 57)||(mail.charCodeAt(i)==95)||(mail.charCodeAt(i)==46))
	{
	 if(mail.charAt(i)=="@")
	  p=p+1
	}
	else
	{
	 u=u+1
	}
   }
   if (p>1)
    alert ("Email must have only one '@'")
   if (u>0)
	 alert ("Special Characters are not allowed")
	if (p==1 && u==0)
	 chkcomments()
  }
 }	
}


