
<!--
// This javascript is used for form validation on a webform containing only selected name and US address information (Include file inc_nameandcontact.php is used.)
function FormValidator()
{
  
  var msg="";
  var pass = true;
  var arr = new Array();
  var emailID = document.requestform.Email.value;
  
  //for forms with the enrollment module
  if (document.requestform['StudentType'])
  {
    var term = "";
    var studentType = "";
    if (document.requestform.but1.checked)
        {
          studentType = "F";
          if ((document.requestform.Term_Year.value) < (document.requestform.Grad_Year.value))
            {
              msg="Enrollment Year cannot be earlier than the High School Graduation Year";
              arr.push(msg);
              document.requestform.Term_Year.focus();
              pass = false;
            }
          if (document.requestform.btn1.checked)
            {
              term = "05";
            }
          if (document.requestform.btn2.checked)
            {
              term = "01";
            }
          if (document.requestform.btn3.checked)
            {
              term = "03";
            }          
        }
    if (document.requestform.but2.checked)
        {
          studentType = "T";
          if (document.requestform.Term_Year.value == "")
            {
              msg="Enrollment Year";
              arr.push(msg);
              document.requestform.Term_Year.focus();
              pass = false;
            }
          if (document.requestform.btn1.checked)
            {
              term = "05";
            }
          if (document.requestform.btn2.checked)
            {
              term = "01";
            }
          if (document.requestform.btn3.checked)
            {
              term = "03";
            }
          if (term == "")
          {
              msg="Enrollment Term";
              arr.push(msg);
              pass = false;
          }
        }
    if (document.requestform.but3.checked)
        {
          studentType = "R";
          if (document.requestform.Term_Year.value == "")
            {
              msg="Enrollment Year";
              arr.push(msg);
              document.requestform.Term_Year.focus();
              pass = false;
            }
          if (document.requestform.btn1.checked)
            {
              term = "05";
            }
          if (document.requestform.btn2.checked)
            {
              term = "01";
            }
          if (document.requestform.btn3.checked)
            {
              term = "03";
            }
          if (term == "")
          {
              msg="Enrollment Term";
              arr.push(msg);
              pass = false;
          }
        }
    if (document.requestform.but4.checked)
        {
          studentType = "N";
          if (document.requestform.Term_Year.value == "")
            {
              msg="Enrollment Year";
              arr.push(msg);
              document.requestform.Term_Year.focus();
              pass = false;
            }
          if (document.requestform.btn1.checked)
            {
              term = "05";
            }
          if (document.requestform.btn2.checked)
            {
              term = "01";
            }
          if (document.requestform.btn3.checked)
            {
              term = "03";
            }
          if (term = "")
          {
              msg="Enrollment Term";
              arr.push(msg);
              pass = false;
          }
        }
    if ((!document.requestform.but1.checked)&&(!document.requestform.but2.checked)&&
    (!document.requestform.but3.checked)&&(!document.requestform.but4.checked))
        {
          msg="Student Type";
          arr.push(msg);
          pass = false;
        }
      }
  
  if (document.requestform['Grad_Year'])
  {
  var gradYear = document.requestform.Grad_Year.value;
  if (gradYear == "")
    {
      msg="HS Graduation Year";
      arr.push(msg);
      document.requestform.Grad_Year.focus();
      pass = false;
    }
  }
  
  if (emailID=="" || echeck(emailID)==false)
  {
	msg="Email Address";
    arr.push(msg);    
    document.requestform.Email.focus();
    pass = false;	
  }  
  
	var zipstr = document.requestform.Zip.value;
  if (zipstr.length < 5)
  {
  	msg="Zipcode";
  	arr.push(msg);    
  	document.requestform.Zip.focus();
  	pass = false;
  }	     
	if (document.requestform.State.value == "")
	{
   	msg="State";
  	arr.push(msg);    
  	document.requestform.State.focus();
  	pass = false;
	}

  if (document.requestform.City.value == "")
  {
    msg="City";
    arr.push(msg);    
    document.requestform.City.focus();
    pass = false;
  }
  
  if (document.requestform.Street.value == "")
  {
    msg = "Street";
    arr.push(msg);
    document.requestform.Street.focus();
    pass = false;
  }

  if (document.requestform.Last_Name.value == "")
  {
    msg = "Last Name";
    arr.push(msg);
    document.requestform.Last_Name.focus();
    pass = false;
  }
   
  if (document.requestform.First_Name.value == "")
  {
    msg="First Name";
    arr.push(msg);
    document.requestform.First_Name.focus();
    pass = false;
  }
  
// For registration forms, number of attendees may be required
  if (document.requestform['Attendees'])
  {
  var attendees = document.requestform.Attendees.value;
	if (attendees == "")
	  {
      msg="Number Attending";
      arr.push(msg);
      document.requestform.Attendees.focus();
      pass = false;
    }
  }

// For registration forms, an event date must be selected
  if (document.requestform['EventDate'])
  {
  var eventDate = document.requestform.EventDate.value;
	if (eventDate == "")
	  {
      msg="Event Date";
      arr.push(msg);
      document.requestform.EventDate.focus();
      pass = false;
    }
  }
  
 if (pass==false)
 {
 	var arr2 = new Array();
	arr2 = arr.reverse();  
	msg="Valid entries are required for the following fields:\n\n\t" + arr2.join("\n\t") +
	"\n\nPlease make corrections and submit form again.";
	alert(msg);
 }   

 return (pass)
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str) {

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr+1){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}


function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

-->


