<!--
function Form1_Validator(theForm)
{

var alertsay = ""; // define for long lines
// alertsay is not necessary for your code,
// but I need to break my lines in multiple lines
// so the code won't extend off the edge of the page




// check if no Title has been selected
if (theForm.title.selectedIndex < 0)
{
alert("Please select one of the \"Title\" options.");
theForm.title.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.title.selectedIndex == 0)
{
alert("Please select one of the \"Title\" options.");
theForm.title.focus();
return (false);
}






// check to see if the First Name field is blank
if (theForm.fname.value == "")
{
alert("You must enter your First Name.");
theForm.fname.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.fname.value.length < 2)
{
alert("Please enter at least 2 characters in the \"First Name\" field.");
theForm.fname.focus();
return (false);
}

// allow ONLY alpha keys, no symbols or punctuation
// this can be altered for any "checkOK" string you desire
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var checkStr = theForm.fname.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 characters in the \"First Name\" field.");
theForm.fname.focus();
return (false);
}

//--------------------------------------------------------------------------------






// check to see if the Last Name field is blank
if (theForm.lname.value == "")
{
alert("You must your Last Name.");
theForm.lname.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.lname.value.length < 2)
{
alert("Please enter at least 2 characters in the \"Last Name\" field.");
theForm.lname.focus();
return (false);
}

// allow ONLY alpha keys, no symbols or punctuation
// this can be altered for any "checkOK" string you desire
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var checkStr = theForm.lname.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 characters in the \"Last Name\" field.");
theForm.lname.focus();
return (false);
}

//--------------------------------------------------------------------------------





// check to see if the Last Name field is blank
if (theForm.btitle.value == "")
{
alert("You must enter your Business Title.");
theForm.btitle.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.btitle.value.length < 2)
{
alert("Please enter at least 2 characters in the \"Business Title\" field.");
theForm.btitle.focus();
return (false);
}

// allow ONLY alpha keys, no symbols or punctuation
// this can be altered for any "checkOK" string you desire
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var checkStr = theForm.btitle.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 characters in the \"Business Title\" field.");
theForm.btitle.focus();
return (false);
}

//--------------------------------------------------------------------------------




// check if email field is blank
if (theForm.email.value == "")
{
alert("Please enter a value for the \"Email\" field.");
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("The \"Email\" field must contain an \"@\" and a \".\".");
theForm.email.focus();
return (false);
}
//------------------------------------------------------------------------




// check if Contact No. field is blank
if (theForm.phone.value == "")
{
alert("Please enter a value for the \"Contact No.\" field.");
theForm.phone.focus();
return (false);
}

// only allow numbers to be entered
var checkOK = "0123456789";
var checkStr = theForm.phone.value;
var allValid = true;
var allNum = "";
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 (ch != ",")
allNum += ch;
}
if (!allValid)
{
alert("Please enter only digit characters in the \"Contact No.\" field.");
theForm.phone.focus();
return (false);
}
//------------------------------------------------------------------------




// check to see if the Company field is blank
if (theForm.cname.value == "")
{
alert("You must your Company Name.");
theForm.cname.focus();
return (false);
}




// check to see if the Address field is blank
if (theForm.address.value == "")
{
alert("You must your Address.");
theForm.address.focus();
return (false);
}




// check to see if the Business Activity field is blank
if (theForm.bizact.value == "")
{
alert("You must your Business Activity.");
theForm.bizact.focus();
return (false);
}




// check if no Country has been selected
if (theForm.events.selectedIndex < 0)
{
alert("Please select one of the \"Events or Occasion\" options.");
theForm.events.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.events.selectedIndex == 0)
{
alert("Please select one of the \"Events or Occasion\" options.");
theForm.events.focus();
return (false);
}

//------------------------------------------------------------------------



// check if no drop down or first drop down is selected, if so, invalid selection
if (theForm.time.selectedIndex <= 0)
{
alert("Please select a Time.");
theForm.time.focus();
return (false);
}
//------------------------------------------------------------------------





// check if no drop down or first drop down is selected, if so, invalid selection
if (theForm.gifts.selectedIndex <= 0)
{
alert("Please select Who are the gifts for?");
theForm.gifts.focus();
return (false);
}
//------------------------------------------------------------------------




// check to see if the Business Activity field is blank
if (theForm.budget.value == "")
{
alert("You must your the Budget per recipient.");
theForm.budget.focus();
return (false);
}





// check if numbers field is blank
if (theForm.quantity.value == "")
{
alert("Please enter a value for the \"Quantity\" field.");
theForm.quantity.focus();
return (false);
}

// only allow numbers to be entered
var checkOK = "0123456789";
var checkStr = theForm.quantity.value;
var allValid = true;
var allNum = "";
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 (ch != ",")
allNum += ch;
}
if (!allValid)
{
alert("Please enter only digit characters in the \"Quantity\" field.");
theForm.quantity.focus();
return (false);
}
//------------------------------------------------------------------------








// because this is a sample page, don't allow to exit to the post action
// comes in handy when you are testing the form validations and don't
// wish to exit the page
return (true);
// replace the above with return(true); if you have a valid form to submit to
}
//-->
