<!--
//**********************************************************************************
// "Internal" function to remove all spaces ensures user input values correctly
//**********************************************************************************
function removeSpaces(s) {
 var tempVal=""
 for(var i=0;i<s.length;++i) {
  var c=s.charAt(i)
  if(c!=" ") tempVal += c
 }
 return tempVal
}


//**********************************************************************************
// "Internal" function to help ensure user input processed correctly
//**********************************************************************************
function checkInvalidChars(s) {
  var errFlag=0
  var firstChar=s.charAt(0);
  for(var i=0;i<s.length;++i) {
	var thisChar=s.charAt(i);
	if((thisChar=="'") || (thisChar==" ")){
	  errFlag = 1
	}
  }
  return errFlag;
}

function checkInvalidOneChar(s) {
  var errFlag=0
  var firstChar=s.charAt(0);
  for(var i=0;i<s.length;++i) {
	var thisChar=s.charAt(i);
	if(thisChar=="'"){
	  errFlag = 1
	}
  }
  return errFlag;
}

function FrontPage_Form2_Validator(theForm)
{

  if (theForm.Student_Id.value == "")
  {
    alert("Please enter a value for the \"User ID\" field.");
    theForm.Student_Id.focus();
    return (false);
  }
  var StudId = removeSpaces(theForm.Student_Id.value);
  if (StudId == "")
  {
    alert("Please enter a value for the \"User ID\" field. It cannot be all spaces.");
	theForm.Student_Id.value = StudId;
    theForm.Student_Id.focus();
    return (false);
  }
  var errFlag = checkInvalidChars(theForm.Student_Id.value);
  if (errFlag > 0)
  {
    alert("The \"User Id\" field contains an invalid character, spaces and apostrophes are not allowed.");
    theForm.Student_Id.focus();
    return (false);
  }
  if (theForm.Student_Id.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"User ID\" field.");
    theForm.Student_Id.focus();
    return (false);
  }

  if (theForm.Student_Id.value.length > 15)
  {
    alert("Please enter at most 15 characters in the \"User ID\" field.");
    theForm.Student_Id.focus();
    return (false);
  }

  if (theForm.Student_Name_Last.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.Student_Name_Last.focus();
    return (false);
  }
  var thisNameValue = removeSpaces(theForm.Student_Name_Last.value);
  if (thisNameValue == "")
  {
    alert("Please enter a value for the \"Last Name\" field. It cannot be all spaces.");
    theForm.Student_Name_Last.value = thisNameValue;
    theForm.Student_Name_Last.focus();
    return (false);
  }
  errFlag = checkInvalidOneChar(theForm.Student_Name_Last.value);
  if (errFlag > 0)
  {
    alert("The \"Last Name\" field contains an invalid character, apostrophes are not allowed.");
    theForm.Student_Name_Last.focus();
    return (false);
  }
  if (theForm.Student_Name_Last.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Last Name\" field.");
    theForm.Student_Name_Last.focus();
    return (false);
  }

  if (theForm.Student_Name_First.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.Student_Name_First.focus();
    return (false);
  }
  thisNameValue = removeSpaces(theForm.Student_Name_First.value);
  if (thisNameValue == "")
  {
    alert("Please enter a value for the \"First Name\" field. It cannot be all spaces.");
    theForm.Student_Name_First.value = thisNameValue;
    theForm.Student_Name_First.focus();
    return (false);
  }
  errFlag = checkInvalidOneChar(theForm.Student_Name_First.value);
  if (errFlag > 0)
  {
    alert("The \"First Name\" field contains an invalid character, apostrophes are not allowed.");
    theForm.Student_Name_First.focus();
    return (false);
  }
  if (theForm.Student_Name_First.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"First Name\" field.");
    theForm.Student_Name_First.focus();
    return (false);
  }

  if (theForm.Company_Name.value == "")
  {
    alert("Please enter a value for the \"Company Name\" field.");
    theForm.Company_Name.focus();
    return (false);
  }
  var thisValue = removeSpaces(theForm.Company_Name.value);
  if (thisValue == "")
  {
    alert("Please enter a value for the \"Company Name\" field. It cannot be all spaces.");
    theForm.Company_Name.value = thisValue;
    theForm.Company_Name.focus();
    return (false);
  }


  if (theForm.Student_Phone.value == "")
  {
    alert("Please enter a value for the \"Phone Number\" field.");
    theForm.Student_Phone.focus();
    return (false);
  }

  if (theForm.Student_Email.value == "")
  {
    alert("Please enter a value for the \"E-Mail\" field.");
    theForm.Student_Email.focus();
    return (false);
  }
  
  thisValue = removeSpaces(theForm.Student_Email.value);
  if (thisValue == "")
  {
    alert("Please enter a value for the \"E-Mail\" field. It cannot be all spaces.");
    theForm.Student_Email.value = thisValue;
    theForm.Student_Email.focus();
    return (false);
  }

  

  if (theForm.Address1.value == "")
  {
    alert("Please enter a value for the \"Address Line 1\" field.");
    theForm.Address1.focus();
    return (false);
  }

  if (theForm.City.value == "")
  {
    alert("Please enter a value for the \"City\" field.");
    theForm.City.focus();
    return (false);
  }
  
  thisValue = removeSpaces(theForm.City.value);
  if (thisValue == "")
  {
    alert("Please enter a value for the \"City\" field. It cannot be all spaces.");
    theForm.City.value = thisValue;
    theForm.City.focus();
    return (false);
  }

  if (theForm.State.value == "")
  {
    alert("Please enter a value for the \"State\" field.");
    theForm.State.focus();
    return (false);
  }

  thisValue = removeSpaces(theForm.State.value);
  if (thisValue == "")
  {
    alert("Please enter a value for the \"State\" field. It cannot be all spaces.");
    theForm.State.value = thisValue;
    theForm.State.focus();
    return (false);
  }
  
  thisValue = removeSpaces(theForm.Zip.value);
  if (thisValue.length == 0)
  {
    alert("Enter a valid Zip Code");
    theForm.Zip.value = thisValue;
    theForm.Zip.focus();
    return (false);
  }    

  var thisPassword = removeSpaces(theForm.Student_Password.value);
  if (thisPassword == "")
  {
    alert("Please enter a value for the \"Password\" field. It cannot be all spaces.");
    theForm.Student_Password.value = thisPassword;
    theForm.Student_Password.focus();
    return (false);
  }
  errFlag = checkInvalidChars(theForm.Student_Password.value);
  if (errFlag > 0)
  {
    alert("The \"Password\" field contains an invalid character, spaces and apostrophes are not allowed.");
    theForm.Student_Password.focus();
    return (false);
  }
  if (theForm.Student_Password.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"Password\" field.");
    theForm.Student_Password.focus();
    return (false);
  }

  if (theForm.Student_Password.value.length > 15)
  {
    alert("Please enter at most 15 characters in the \"Password\" field.");
    theForm.Student_Password.focus();
    return (false);
  }

  return (true);
}


//-->
