
<!--
// This javascript is used for form validation on most Talisma webforms. Specific address fields required and validation is dependent on Country selected.  Typically used on webform using include files inc_name.php and inc_contact.php.

function FormValidator()
{
  
  var msg="";
  var pass = true;
  var arr = new Array();

  // Only on distance request form
  if (document.requestform['Program'])
  {
    var programObj = document.requestform.Program;
    var length = programObj.length;
    if (length != undefined)
	  {
    	var boolSel = false;
		  for (var i=0; i<length; i++)
		  {
		    if (programObj[i].checked)
		      boolSel = true;
		  }
		  if (boolSel == false)
    	{
      		msg="ISU Enrollment-Programs of Interest";
      		arr.push(msg);
      		pass = false;
      }
    }
  }
  
// Only on campus visit form
//
  if (document.requestform['Tshirt_Size'])
  {
  var Tshirt_Size = document.requestform.Tshirt_Size.value;
	if (Tshirt_Size == "")
	  {
      msg="Tshirt Size";
      arr.push(msg);
      document.requestform.Tshirt_Size.focus();
      pass = false;
    }
  }
  if (document.requestform['VisitDate'])
  {
    if (document.requestform.VisitDate.value == "")
    {
      msg="Visit Date";
      arr.push(msg);    
      document.requestform.VisitDate.focus();
      pass = false;
    }
  }  
  if (document.requestform['VisitTime'])
  {
    if (document.requestform.VisitTime.value == "")
    {
      msg="Visit Time";
      arr.push(msg);    
      document.requestform.VisitTime.focus();
      pass = false;
    }
  } 
  if (document.requestform['AcademicAppt'])
  {
    if (document.requestform.AcademicAppt.checked)
    {
      if (document.requestform.Interest.value == "")
      {
      msg="Academic Appt Area";
      arr.push(msg);    
      if (document.requestform.Interest.enabled)
        document.requestform.Interest.focus();
      pass = false;
      }
    }
  } 
  if (document.getElementById('phonereq'))
  {
    if (document.getElementById('phonereq').style.display == 'inline')
    {
      var phone1 = document.requestform['Phone1'].value;
      var phone2 = document.requestform['Phone2'].value;
      var phone3 = document.requestform['Phone3'].value;
      var valPhone = false;
      if (phone1.length==3 && phone2.length==3 && phone3.length==4)
      {
        valPhone = true;
      }
      if (valPhone == false)
      {
        msg="Phone Number";
        arr.push(msg);
        document.requestform.Phone1.focus();
        pass=false;
      }    
  }
  }
//
// end of extra campus visit form validation

  var emailID = document.requestform.Email.value;
  
  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['DOB_Month'] && document.requestform['DOB_Day'] )
  { 
    var month = document.requestform.DOB_Month.value;
    var day = document.requestform.DOB_Day.value;
	  var year = document.requestform.DOB_Year.value;    
    var validBD = false;
  	if (month !="" && day!="" && year.length==4)
  	{
  		validBD = true;
  	}
  	if (validBD == false)
    {
      	msg="Birth Date";
      	arr.push(msg);
      	document.requestform.DOB_Month.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, 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\t" + arr2.join("\n\t") +
	"\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;
}

-->

