// Site Form Validation

// ============== Newsletter Sign-up Validation =============== //


function FormNewsletter_Validator(theForm)
{
	
	// check to see if the field is blank
if (theForm.name.value == "")
{
alert("Please enter your full name.");
theForm.name.focus();
return (false);
}


// check to see if the field is blank
if (theForm.email.value == "")
{
alert("Please enter your email address.");
theForm.email.focus();
return (false);
}

// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.email.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkEmail.length;  j++)
{
if (ch == checkEmail.charAt(j) && ch == "@")
EmailAt = true;
if (ch == checkEmail.charAt(j) && ch == ".")
EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
if (EmailAt && EmailPeriod)
{
		EmailValid = true
		break;
	}
}
if (!EmailValid)
{
alert("Please enter a valid email address.");
theForm.email.focus();
return (false);
}

return (true);
}

// ============== Update Email Address ================ //

function FormEmail_Validator(theForm)
{


// check to see if the field is blank
if (theForm.email_address.value == "")
{
alert("Please enter your email address.");
theForm.email_address.focus();
return (false);
}

// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.email_address.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkEmail.length;  j++)
{
if (ch == checkEmail.charAt(j) && ch == "@")
EmailAt = true;
if (ch == checkEmail.charAt(j) && ch == ".")
EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
if (EmailAt && EmailPeriod)
{
		EmailValid = true
		break;
	}
}
if (!EmailValid)
{
alert("Please enter a valid email address.");
theForm.email_address.focus();
return (false);
}


// check to see if the field is blank
if (theForm.email_address_2.value == "")
{
alert("Please retype your email address.");
theForm.email_address_2.focus();
return (false);
}

// check if both email fields are the same
if (theForm.email_address.value != theForm.email_address_2.value)
{
	alert("Your email addresses do not match. Please double-check your email address and retype.");
	theForm.email_address_2.focus();
	return (false);
}

return (true);
}


// =============== Change Password  ======================= //

<!--
function FormPassword_Validator(theForm)
{


// require at least 5 characters in the password field
if (theForm.password.value.length < 6)
{
alert("Please enter at least 6 characters for your Password.");
theForm.password.focus();
return (false);
}

// require at least 5 characters in the password field
if (theForm.password.value.length > 15)
{
alert("Please enter no more than 15 characters for your Password.");
theForm.password.focus();
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
// this can be altered for any "checkOK" string you desire
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var checkStr = theForm.password.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please enter only letter and numbers for your Password.");
theForm.password.focus();
return (false);
}


// check if both password fields are the same
if (theForm.password.value != theForm.password2.value)
{
	alert("Your passwords do not match.  Please retype your password.");
	theForm.password2.focus();
	return (false);
}


//disable form button
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theForm.length;i++){
var tempobj=theForm.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}

return (true);
}



// =================== Join Form Validation =================//

<!--
function FormJoin_Validator(theForm)
{

// check to see if the field is blank
if (theForm.first_name.value == "")
{
alert("Please enter your first name.");
theForm.first_name.focus();
return (false);
}

// check to see if the field is blank
if (theForm.last_name.value == "")
{
alert("Please enter your last name.");
theForm.last_name.focus();
return (false);
}

// check if no drop down or first drop down is selected, if so, invalid selection
if (theForm.state.selectedIndex <= 0)
{
alert("Please select a state.");
theForm.state.focus();
return (false);
}

// check if no drop down or first drop down is selected, if so, invalid selection
if (theForm.country.selectedIndex <= 0)
{
alert("Please select a country.");
theForm.country.focus();
return (false);
}

// check if no drop down or first drop down is selected, if so, invalid selection
if (theForm.entrepreneurial_stage.selectedIndex <= 0)
{
alert("Please select an Entrepreneurial Stage.");
theForm.entrepreneurial_stage.focus();
return (false);
}

// check if no drop down or first drop down is selected, if so, invalid selection
if (theForm.how_heard.selectedIndex <= 0)
{
alert("Please select how you heard about us.");
theForm.how_heard.focus();
return (false);
}

// check to see if the field is blank
if (theForm.email_address.value == "")
{
alert("Please enter your email address.");
theForm.email_address.focus();
return (false);
}

// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.email_address.value;
var EmailValid = false;
var EmailAt = false;
var EmailPeriod = false;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkEmail.length;  j++)
{
if (ch == checkEmail.charAt(j) && ch == "@")
EmailAt = true;
if (ch == checkEmail.charAt(j) && ch == ".")
EmailPeriod = true;
	  if (EmailAt && EmailPeriod)
		break;
	  if (j == checkEmail.length)
		break;
	}
	// if both the @ and . were in the string
if (EmailAt && EmailPeriod)
{
		EmailValid = true
		break;
	}
}
if (!EmailValid)
{
alert("Please enter a valid email address.");
theForm.email_address.focus();
return (false);
}


// check to see if the field is blank
if (theForm.email_address_2.value == "")
{
alert("Please retype your email address.");
theForm.email_address_2.focus();
return (false);
}

// check if both password fields are the same
if (theForm.email_address.value != theForm.email_address_2.value)
{
	alert("Your email addresses do not match. Please double-check your email address and retype.");
	theForm.email_address_2.focus();
	return (false);
}


// require at least 5 characters in the password field
if (theForm.password.value.length < 6)
{
alert("Please enter at least 6 characters for your Password.");
theForm.password.focus();
return (false);
}

// require at least 5 characters in the password field
if (theForm.password.value.length > 15)
{
alert("Please enter no more than 15 characters for your Password.");
theForm.password.focus();
return (false);
}

// allow ONLY alphanumeric keys, no symbols or punctuation
// this can be altered for any "checkOK" string you desire
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var checkStr = theForm.password.value;
var allValid = true;
for (i = 0;  i < checkStr.length;  i++)
{
ch = checkStr.charAt(i);
for (j = 0;  j < checkOK.length;  j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
if (!allValid)
{
alert("Please enter only letter and numbers for your Password.");
theForm.password.focus();
return (false);
}


// check if both password fields are the same
if (theForm.password.value != theForm.password_2.value)
{
	alert("Your passwords do not match.  Please retype your password.");
	theForm.password_2.focus();
	return (false);
}


//disable form button
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theForm.length;i++){
var tempobj=theForm.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}

return (true);
}
//-->
