function validateForm(frm1)
{

  pass = 1; //assume everything is ok
  msg = "The following problems were found when trying to submit this form:\n\n";

  //make sure required fields are not empty
  	if (isEmpty(frm1.fname.value))
  		{
  		  msg = msg + "- First Name cannot be empty\n";
   		 pass = 0;
  		}
  
  
  
   			if (isEmpty(frm1.lname.value))
  			{
  			  msg = msg + "- Last Name cannot be empty\n";
   			 pass = 0;
 			 }
  
   
  if (isEmpty(frm1.email.value))
  {
    msg = msg + "- Email cannot be empty\n";
    pass = 0;
  }
  
  
 
  
   if(isEmpty(frm1.org.value))
   {
   
    msg = msg + "-Organization name can not be empty\n";
    pass = 0;
   
   }
   
 //validate the email address
  if (!(isEmail(frm1.email.value)))
 {
    msg = msg + "- Please enter a valid email address\n";
    pass = 0;
  }
  
  
  
   if(frm1.phone.value!="")
{
  
   var phone1=frm1.phone.value;
   var phone2=frm1.phone2.value;
   var phone3=frm1.phone3.value;
 
    phone=phone1+phone2+phone3;
	
  if(!isNum(phone))
   {
   
    msg = msg + "-Please enter a valid phone number\n";
    pass = 0;
   
   }
   if(phone.length < 10)
   {
   
  msg = msg + "-Please enter a valid 10 digit phone number\n";
    pass = 0;
   }


  }
   
  
    if(frm1.nop.value!="")
{
  
  if(!isNum(frm1.nop.value))
   {
   
    msg = msg + "-Please enter digits only for number of people\n";
    pass = 0;
   
   }
  
   
  }
  
  
  if(frm1.comments.value!="")
{
 var str=frm1.comments.value;
  
  var pos1 = str.indexOf (">");
   
  if (pos1>-1)
  {
  
  alert("invalid character >");
  return false;
  }
  var pos2 =str.indexOf("< ");
  if (pos2>-1)
  {
  
  alert("invalid character < ");
  return false;
  }
  var pos3 =str.indexOf("%20");
  if (pos3>-1)
  {
  
  alert("invalid character %20");
  return false;
  }
  
  
   var pos4 =str.indexOf("'");
  if (pos4>-1)
  {
  
  alert("invalid character '");
  return false;
  }
   var pos5 =str.indexOf("=");
  if (pos5>-1)
  {
  
  alert("invalid character =");
  return false;
  }
   var pos6 =str.indexOf("*");
  if (pos6>-1)
  {
  
  alert("invalid character *");
  return false;
  }
   var pos7 =str.indexOf("%");
  if (pos7>-1)
  {
  
  alert("invalid character %");
  return false;
  }
  
  
  
  }
   if (pass == 1)
  {
    return true;
  }
  else
  {
    alert(msg);
    return false;
  }
  
 
  

}

// validators ------------------------------------------------------------------

	
function isEmpty (s) {
	var p = /\S+/;
	return !p.test(s);
}

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}


function isNum(string) {
    if (string.search(/^[0-9]+$/) != -1)
        return true;
    else
        return false;
}

