function valid_required(field)
{
         if(field=="")          {
         return false;
         
         }
    return true;
}
         		
		
		
function ValidDate(field)
{
	if(field=="")
	{
	alert("Date of Birth required field!")
	return false;
	field.focus();
	field.select();
	}
	

	 var valid = "0123456789-";
	var slashcount = 0;

	if (field.length!=10) 
	{
	alert("Invalid date! The correct date format is '10-01-1986'.")
	return false;
	}
		for (var i=0; i < field.length; i++)
		{
		temp = "" + field.substring(i, i+1);
		if (temp == "-") 
		slashcount++;
			if (valid.indexOf(temp) == "-1") 
			{
			alert("Invalid characters in your date.  Please try again.")
			return false;
			}
		if (slashcount > 2) 
		{
alert("Invalid Date!  The slash character should be used with a properly formatted 8 digits like  '10-01-1986'.   Please try again.")
		return false;
  		}
		if((field.charAt(2)!= '-')||(field.charAt(5) != '-'))
		{
alert("Invalid date! The dash character should be used with a properly formatted 8 digits like  '10-01-1986'.")
		return false;
		}
	}
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
var matchArray = field.match(datePat); // is the format ok?
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.")
return false;
}
if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.")
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn't have 31 days!")
return false
}
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
alert("February " + year + " doesn't have " + day + " days!")
return false;
   }
   }
  if (year<1940 || year>1995) {
alert("Year "+year+" is not valid! Please enter Year from 1940 to 1995")
return false;
}
return true;
}

function ValidDateHS(field1)
{
	if(field1=="")
	{
	alert("High School Graduation Date is required field!")
	return false;
	field1.focus();
	field1.select();
	}
	

	 var validHS = "0123456789-";
	var slashcountHS = 0;

	if (field1.length!=10) 
	{
	alert("Invalid date! The correct date format for High School Graduation Date is '10-01-2006'.")
	return false;
	}
		for (var i=0; i < field1.length; i++)
		{
		temp = "" + field1.substring(i, i+1);
		if (temp == "-") 
		slashcountHS++;
			if (validHS.indexOf(temp) == "-1") 
			{
			alert("Invalid characters in your High School Graduation date.  Please try again.")
			return false;
			}
		if (slashcountHS > 2) 
		{
alert("Invalid High School Graduation Date!  The slash character should be used with a properly formatted 8 digits like  '10-01-1986'.   Please try again.")
		return false;
  		}
		if((field1.charAt(2)!= '-')||(field1.charAt(5) != '-'))
		{
alert("Invalid High School Graduation date! The dash character should be used with a properly formatted 8 digits like  '10-01-2006'.")
		return false;
		}
	}
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
var matchArray = field1.match(datePat); // is the format ok?
monthHS = matchArray[1]; // parse date into variables
dayHS = matchArray[3];
yearHS = matchArray[4];
if (monthHS < 1 || monthHS > 12) { // check month range
alert("Month must be between 1 and 12.")
return false;
}
if (dayHS < 1 || dayHS > 31) {
alert("Day must be between 1 and 31.")
return false;
}
if ((monthHS==4 || monthHS==6 || monthHS==9 || monthHS==11) && dayHS==31) {
alert("Month "+monthHS+" doesn't have 31 days!")
return false
}
if (monthHS == 2) { // check for february 29th
var isleap = (yearHS % 4 == 0 && (yearHS % 100 != 0 || yearHS % 400 == 0));
if (dayHS>29 || (dayHS==29 && !isleap)) {
alert("February " + yearHS + " doesn't have " + dayHS + " days!")
return false;
   }
   }
  if (yearHS<1960 || yearHS>2013) {
alert("Year "+yearHS+" is not valid High School Graduation Year! Please enter  from 1960 to 2013")
return false;
}
return true;
}



function ValidPhone(aphone)
{
// declare valid variable as a string with all valid characters (digits from 0 to 9 )
    var valid = "0123456789-";
    var slashcount = 0;
//if phone field is empty - display a warning and return false
         if(aphone=="")
         {
    alert ("Phone number field is required. Please enter phone number in 123-123-1233 format!")
         return false;
         }
//if number of character in phone field is not equal 10 - display warning and return false
         if(aphone.length !=12)
         {
    alert("Invalid phone number length! Please enter phone number in 123-123-1233 format!")
         return false;
         }
        //check each character entered in the phone field
         for (var i=0; i < aphone.length; i++)
		 {
		temp = "" + aphone.substring(i, i+1);
		if (temp == "-") 
		 {
		slashcount++;
		    }
			if (valid.indexOf(temp) == "-1") 
			{
			alert("Invalid characters in your phone number.  Please try again.")
			return false;
			}
			if((aphone.charAt(3)!= '-')||(aphone.charAt(7) != '-'))
		    {
		    alert("Invalid date! The dash character should be used with a properly formatted 10 digits like  '215-345-1234'.   Please try again.")
		   return false;
		   }
    }
    //if all conditions are passed, then return true
    return true;
}

function ValidOtherPhone(aphone)
{
// declare valid variable as a string with all valid characters (digits from 0 to 9 )
    var valid = "0123456789-";
    var slashcount = 0;
//if phone field is empty - display a warning and return false
         if(aphone=="")
         {
    alert ("Cell/Work phone field is required. Please enter phone number in 215-233-2222 format!")
         return false;
         }
//if number of character in phone field is not equal 10 - display warning and return false
         if(aphone.length !=12)
         {
    alert("Invalid Cell/Work phone number length! Please enter phone number in 215-233-2222 format.")
         return false;
         }
        //check each character entered in the phone field
         for (var i=0; i < aphone.length; i++)
		 {
		temp = "" + aphone.substring(i, i+1);
		if (temp == "-") 
		 {
		slashcount++;
		    }
			if (valid.indexOf(temp) == "-1") 
			{
			alert("Invalid characters in your cell/work phone number.  Please enter phone number in 215-333-2222 format.")
			return false;
			}
			if((aphone.charAt(3)!= '-')||(aphone.charAt(7) != '-'))
		    {
		 alert("Invalid date! The dash character should be used with a properly formatted 10 digits .Please enter phone number in 215-333-2222 format.")
		   return false;
		   }
    }
    //if all conditions are passed, then return true
    return true;
}


function ValidSS(ss)
{
// declare valid variable as a string with all valid characters (digits from 0 to 9 )
    var ssvalid = "0123456789-";
    var slashcount = 0;
//if phone field is empty - display a warning and return false
         if(ss=="")
         {
    alert ("The Social Security info is required. Please enter SS number in this format 154-12-7777!")
         return false;
         }
//if number of character in phone field is not equal 10 - display warning and return false
         if(ss.length !=11)
         {
    alert("Invalid SS length! Please enter SS number in this format 154-12-7777")
         return false;
         }
        //check each character entered in the phone field
      for (var i=0; i < ss.length; i++)
		 {
		temp = "" + ss.substring(i, i+1);
		if (temp == "-") 
		 {
		slashcount++;
		    }
			if (ssvalid.indexOf(temp) == "-1") 
			{
			alert("Invalid characters in your SS.  Please enter SS number in this format 154-12-7777")
			return false;
			}
			if((ss.charAt(3)!= '-')||(ss.charAt(6) != '-'))
		    {
		    alert("Invalid character! Please enter SS number in this format 154-12-7777")
		   return false;
		   }
    }
    //if all conditions are passed, then return true
    return true;
}

function ValidDateHS_OLD(field)
{
	if(field=="")
	{
	alert("Date of High School Graduation is required field!")
	return false;
	}
	

	 var valid = "0123456789-";
	var slashcount = 0;

	if (field.length!=10) 
	{
	alert("Invalid date! The correct date format is '10-01-1986'.")
	return false;
	}
		for (var i=0; i < field.length; i++)
		{
		temp = "" + field.substring(i, i+1);
		if (temp == "-") 
		slashcount++;
			if (valid.indexOf(temp) == "-1") 
			{
			alert("Invalid characters in your date.  Please try again.")
			return false;
			}
		if (slashcount > 2) 
		{
alert("Invalid Date!  The dash character should be used with a properly formatted 8 digits like  '10-01-1986'.")
		return false;
  		}
		if((field.charAt(2)!= '-')||(field.charAt(5) != '-'))
		{
alert("Invalid date! The dash character should be used with a properly formatted 8 digits like  '10-01-1986'.")
		return false;
		}
	}
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
var matchArray = field.match(datePat); // is the format ok?
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.")
return false;
}
if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.")
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn't have 31 days!")
return false
}
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
alert("February " + year + " doesn't have " + day + " days!")
return false;
   }
   }
  if (year<1950 || year>2011) {
alert("Year "+year+" is not valid! Please enter Year from 1950 to 2011")
return false;
}
return true;
}

function ValidDateCollege(field)
{

	 var valid = "0123456789-";
	var slashcount = 0;

	if (field.length!=10) 
	{
	alert("Invalid date! The correct date format is '10-01-1986'.")
	return false;
	}
		for (var i=0; i < field.length; i++)
		{
		temp = "" + field.substring(i, i+1);
		if (temp == "-") 
		slashcount++;
			if (valid.indexOf(temp) == "-1") 
			{
			alert("Invalid characters in your date.  Please try again.")
			return false;
			}
		if (slashcount > 2) 
		{
alert("Invalid Date!  The dash character should be used with a properly formatted 8 digits like  '10-01-1986'.   Please try again.")
		return false;
  		}
		if((field.charAt(2)!= '-')||(field.charAt(5) != '-'))
		{
alert("Invalid date! The dash character should be used with a properly formatted 8 digits like  '10-01-1986'.")
		return false;
		}
	}
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
var matchArray = field.match(datePat); // is the format ok?
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.")
return false;
}
if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.")
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn't have 31 days!")
return false
}
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
alert("February " + year + " doesn't have " + day + " days!")
return false;
   }
   }
  if (year<1950 || year>2011) {
alert("Year "+year+" is not valid! Please enter Year from 1950 to 2011")
return false;
}
return true;
}

function ValidCEEB(ss)
{
// declare valid variable as a string with all valid characters (digits from 0 to 9 )
    var ssvalid = "0123456789";
    var IsNumber=true;
    var Char;
    //var slashcount = 0;
//if phone field is empty - display a warning and return false
         if(ss=="")
         {
    alert ("The CEEB info is required. Please enter CEEB number in this format 154127!")
         return false;
         }
//if number of character in phone field is not equal 10 - display warning and return false
         if(ss.length !=6)
         {
    alert("Invalid CEEB length! Please enter CEEB number in this format 154127!")
         return false;
         }
     for (i = 0; i < ss.length && IsNumber == true; i++) 
      { 
      Char = ss.charAt(i); 
      if (ssvalid.indexOf(Char) == -1) 
         {
         alert("Invalid CEEB characters! Please enter CEEB number in this format 154127!")
         return false;
          }
         }
          //if all conditions are passed, then return true
    return true;
}

function ValidYearHS(ss)
{
// declare valid variable as a string with all valid characters (digits from 0 to 9 )
    var ssvalid = "0123456789";
    var IsNumber=true;
    var Char;
    //var slashcount = 0;
//if phone field is empty - display a warning and return false
         if(ss=="")
         {
    alert ("The High Graduating Year field is required. Please enter High School Graduation Year in this format 1999!")
         return false;
         }
//if number of character in phone field is not equal 10 - display warning and return false
         if(ss.length !=4)
         {
    alert("Invalid High School Year length! Please enter High School year  in this format 1999!")
         return false;
         }
     for (i = 0; i < ss.length && IsNumber == true; i++) 
      { 
      Char = ss.charAt(i); 
      if (ssvalid.indexOf(Char) == -1) 
         {
         alert("You entered Invalid characters for High School Graduating Year field! Please enter High School number in this format 1999!")
         return false;
          }
         if (ss<1960 || ss>2013) {
         alert("The High School Graduating Year "+ss+" is not valid! Please enter Year from 1960 to 2013")
         return false;
           }
         }
          //if all conditions are passed, then return true
    return true;
}

function EmailValid(aemail)
{
    //if email field is empty - warning displays and return false
         if(aemail=="")
         {
    alert ("Email address field is required. Please enter email myemail@mysite.com")
         return false;
         }
         //get email string length
         len = aemail.length;

         //check position of @ character.
         //it may be anywhere but not in the beginning or at the end of string.
         if((aemail.charAt(1)=='@')||(aemail.charAt(1)=='.'))
         {
    alert ("Invalid email. Please enter email like myemail@mysite.com")
         return false;
         }
         if((aemail.charAt(len-2)=='@')||(aemail.charAt(len-2)=='.'))
         {
    alert ("Invalid email. Please enter email like myemail@mysite.com")
         return false;
         }
    //count number of @ occurrences and number of dot occurrences
         count=0;
         
    for (i=0; i< aemail.length; i++)
    {
         if(aemail.charAt(i)=='@')
         count++;

          }
    //if @ or dot occurs not once display warning and return false
         if(count !=1)
         {
    alert ("Invalid email. Please enter email like myemail@mysite.com")
         return false;
    }
    return true;
}

