function validate(theform)
{

if (theform.pname.value=="")
 {
 alert("Please enter the recipient's name.");
 theform.pname.focus();
 theform.pname.select();
 return false;
 }
else
 {
 for(var i=0;i<theform.pname.value.length;i++)
  {
   if(theform.pname.value.charAt(i)<'A' ||  theform.pname.value.charAt(i)>'Z')
    {
      if(theform.pname.value.charAt(i)<'a' ||  theform.pname.value.charAt(i)>'z')
      {
       if(!((theform.pname.value.charAt(i)=='.') || (theform.pname.value.charAt(i)==' ')))
        {
          alert("Only alphabets, a space and a . are allowed in the name field.");
          theform.pname.select();
          theform.pname.focus();
          return false;
        }
      }
    }
  }
 }

if (theform.address.value=="")
 {
   alert("Please enter the recipient's address.");
   theform.address.focus();
   theform.address.select();
   return false;
 }

if(theform.address.value!="")
{
var str=theform.address.value
str=str.toLowerCase()

	if(str.indexOf("http")!=-1 || str.indexOf("www")!=-1)
	{
	     alert("urls not accepted.")
 	     theform.address.select();
	     theform.address.focus();
             return false;
	}
}




if (theform.city.value=="")
 {
    alert("Please enter the city where the recipient resides.");
    theform.city.focus();
    theform.city.select();
    return false;
 }
else
 {
  for(var i=0;i<theform.city.value.length;i++)
  {
    if(theform.city.value.charAt(i)<'A' ||  theform.city.value.charAt(i)>'Z')
   {
     if(theform.city.value.charAt(i)<'a' ||  theform.city.value.charAt(i)>'z')
    {
     if(!((theform.city.value.charAt(i)=='.') || (theform.city.value.charAt(i)==' ')))
     {
       alert("Only alphabets, a space and a . are allowed in the City field.");
       theform.city.select();
       theform.city.focus();
       return false;
     }
    }
   }
  }
 }

 if (theform.pincode.value=="")
 {
  alert("Please enter pincode of the recipient.");
  theform.pincode.focus();
  theform.pincode.select();
  return false;
 }
else
 {
    a = theform.pincode.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 pincode field.");
      theform.pincode.select();
      theform.pincode.focus();
      return false;
    }
   }
  }
 }

 if (theform.phone.value=="")
 {
  alert("Please enter the recipient's phone number.");
  theform.phone.focus();
  theform.phone.select();
  return false;
 }
else
 {
   a = theform.phone.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.phone.select();
      theform.phone.focus();
      return false;
    }
   }
  }
 }

if (theform.messg.value=="")
 {
  alert("Please enter your message.");
  theform.messg.focus();
  theform.messg.select();
  return false;
 }

if (theform.senders.value=="")
 {
  alert("Please enter the senders name.");
  theform.senders.focus();
  theform.senders.select();
  return false;
 }

else
 {
  for(var i=0;i<theform.senders.value.length;i++)
  {
   if(theform.senders.value.charAt(i)<'A' ||  theform.senders.value.charAt(i)>'Z')
   {
    if(theform.senders.value.charAt(i)<'a' ||  theform.senders.value.charAt(i)>'z')
    {
     if(!((theform.senders.value.charAt(i)=='.') || (theform.senders.value.charAt(i)==' ')))
     {
       alert("Only alphabets, a space and a . are allowed in the name field.");
       theform.senders.select();
       theform.senders.focus();
       return false;
     }
    }
   }
  }
 }

 var charge,curr;
 charge=theform.messg.value.length;
 if (charge<=7500)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 20/-."); 
 else
 {
    curr=Math.round((charge-7500)/2300)   
   if (curr<=1)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 30/-.");
   else
     if (curr>1 && curr<=2)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 40/-.");
   else
     if (curr>2 && curr<=3)
    alert("You have entered  " + theform.messg.value.length + "  characters and it is going to cost you Rs 50/-.");
   else
    if (curr>3 && curr<=4)
    alert("You have entered  " + theform.messg.value.length + "  characters and it is going to cost you Rs 60/-.");
   else
    if (curr>4 && curr<=5)
    alert("You have entered  " + theform.messg.value.length + "  characters and it is going to cost you Rs 70/-.");
   else
    if (curr>5 && curr<=6)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 80/-.");
   else
    if (curr>6 && curr<=7)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 90/-.");
   else
    if (curr>7 && curr<=8)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 100/-.");
   else
    if (curr>8 && curr<=9)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 110/-.");
   else
    if (curr>9 && curr<=10)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 120/-.");
   else
    if (curr>10 && curr<=11)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 130/-.");
   else
    if (curr>11 && curr<=12)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 140/-.");
   else    
    if (curr>12 && curr<=13)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 150/-.");
   else   
    if (curr>13 && curr<=14)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 160/-.");
   else
    if (curr>14 && curr<=15)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 170/-.");
   else
    if (curr>15 && curr<=16)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 180/-.");
   else
    if (curr>16 && curr<=17)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 190/-.");
   else
    if (curr>17 && curr<=18)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 200/-.");
   else   
    if (curr>18 && curr<=19)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 210/-.");
   else
    if (curr>19 && curr<=20)
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 220/-.");
   else   
    alert("You have entered  " + theform.messg.value.length + "  characters and the charges are Rs 230/-.");
  }
return true;
}

