function Form1_Validator(theForm)
{


//document.getElementById('pleasewait').style.visibility="visible";


var alertsay = ""; 
// check to see if the field is blank

if (theForm.date_one.value == "")
{
alert("Please enter a valid date in the \"Date\" field");
theForm.date_one.focus();
return (false);
}

if (theForm.date_one.value.length < 6)
{
alert("Please enter at least 6 characters in the \"Date\" field");
theForm.date_one.focus();
return (false);
}


if (theForm.submitter.value == "")
{
alert("Please enter name in the \"Attorney Name\" field");
theForm.submitter.focus();
return (false);
}

if (theForm.submitter.value.length < 6)
{
alert("Please enter at least 6 characters in the \"Attorney Name\" field");
theForm.submitter.focus();
return (false);
}


if (theForm.oldfirm.value == "")
{
alert("Please enter former law firm name in the \"Law Firm\" field");
theForm.oldfirm.focus();
return (false);
}

if (theForm.oldfirm.value.length < 6)
{
alert("Please enter at least 6 characters in the \"Law Firm\" field");
theForm.oldfirm.focus();
return (false);
}


if (theForm.date_two.value == "")
{
alert("Please enter a valid date in the \"Date\" field");
theForm.date_two.focus();
return (false);
}

if (theForm.date_two.value.length < 6)
{
alert("Please enter at least 6 characters in the \"Date\" field");
theForm.date_two.focus();
return (false);
}


if (theForm.newfirm.value == "")
{
alert("Please enter new law firm name in the \"Law Firm\" field");
theForm.newfirm.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.newfirm.value.length < 6)
{
alert("Please enter at least 6 characters in the \"Law Firm\" field");
theForm.newfirm.focus();
return (false);
}


if (theForm.addr.value == "")
{
alert("Please enter street address in the \"Address\" field");
theForm.addr.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.addr.value.length < 5)
{
alert("Please enter at least 5 characters in the \"Address\" field");
theForm.addr.focus();
return (false);
}


if (theForm.city.value == "")
{
alert("Please enter city in the \"City\" field");
theForm.city.focus();
return (false);
}

// require at least 2 characters be entered
if (theForm.city.value.length < 2)
{
alert("Please enter at least 2 characters in the \"City\" field");
theForm.city.focus();
return (false);
}


if (theForm.zip.value == "")
{
alert("Please enter zip code in the \"Zip Code\" field");
theForm.zip.focus();
return (false);
}

// require at least 5 characters be entered
if (theForm.zip.value.length < 5)
{
alert("Please enter at least 5 numeric characters in the \"Zip Code\" field");
theForm.zip.focus();
return (false);
}


if (theForm.pnum.value == "")
{
alert("Please enter phone number in the \"Phone Number\" field");
theForm.pnum.focus();
return (false);
}

// require at least 10 characters be entered
if (theForm.pnum.value.length < 10)
{
alert("Please enter at least 10 numeric characters in the \"Phone Number\" field");
theForm.pnum.focus();
return (false);
}


if (theForm.Email.value == "")
{
alert("Please enter a valid email address 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);
}












if (theForm.attorney.value == "")
{
alert("Please enter new attorney name in the \"Attorney Name\" field");
theForm.attorney.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.attorney.value.length < 6)
{
alert("Please enter at least 6 characters in the \"Attorney Name\" field");
theForm.attorney.focus();
return (false);
}


if (theForm.addr2.value == "")
{
alert("Please enter street address in the \"Address\" field");
theForm.addr2.focus();
return (false);
}

// require at least 3 characters be entered
if (theForm.addr2.value.length < 6)
{
alert("Please enter at least 6 characters in the \"Address\" field");
theForm.addr2.focus();
return (false);
}


if (theForm.city2.value == "")
{
alert("Please enter city in the \"City\" field");
theForm.city2.focus();
return (false);
}

// require at least 2 characters be entered
if (theForm.city2.value.length < 2)
{
alert("Please enter at least 2 characters in the \"City\" field");
theForm.city2.focus();
return (false);
}


if (theForm.zip2.value == "")
{
alert("Please enter zip code in the \"Zip Code\" field");
theForm.zip2.focus();
return (false);
}

// require at least 5 characters be entered
if (theForm.zip2.value.length < 5)
{
alert("Please enter at least 5 numeric characters in the \"Zip Code\" field");
theForm.zip.focus();
return (false);
}


if (theForm.pnum2.value == "")
{
alert("Please enter phone number in the \"Phone Number\" field");
theForm.pnum2.focus();
return (false);
}

// require at least 10 characters be entered
if (theForm.pnum2.value.length < 10)
{
alert("Please enter at least 10 numeric characters in the \"Phone Number\" field");
theForm.pnum2.focus();
return (false);
}


if (theForm.Email2.value == "")
{
alert("Please enter a valid email address for the \"Email\" field.");
theForm.Email2.focus();
return (false);
}


// test if valid email address, must have @ and .
var checkEmail = "@.";
var checkStr = theForm.Email2.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.Email2.focus();
return (false);
}


if (theForm.signfiler.value == "")
{
alert("Please enter name in the \"Typed Name of Authorized Filer\" field");
theForm.signfiler.focus();
return (false);
}

// require at least 10 characters be entered
if (theForm.signfiler.value.length < 5)
{
alert("Please enter at least 5 characters in the \"Typed Name of Authorized Filer\" field");
theForm.signfiler.focus();
return (false);
}

if (theForm.date_three.value == "")
{
alert("Please enter a valid date in the \"Date\" field");
theForm.date_three.focus();
return (false);
}

if (theForm.date_three.value.length < 6)
{
alert("Please enter at least 6 characters in the \"Date\" field");
theForm.date_three.focus();
return (false);
}


if (theForm.signrep.value == "")
{
alert("Please enter name in the \"Typed Name of Former Firm Representative\" field");
theForm.signrep.focus();
return (false);
}

// require at least 5 characters be entered
if (theForm.signrep.value.length < 5)
{
alert("Please enter at least 5 characters in the \"Typed Name of Former Firm Representative\" field");
theForm.signrep.focus();
return (false);
}


if (theForm.date_four.value == "")
{
alert("Please enter a valid date in the \"Date\" field");
theForm.date_four.focus();
return (false);
}

if (theForm.date_four.value.length < 6)
{
alert("Please enter at least 6 characters in the \"Date\" field");
theForm.date_four.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


if (theForm.division.selectedIndex < 0)
{
alert("Please select one of the \"Division Location\" options.");
theForm.division.focus();
return (false);
}

// check if the first drop down is selected, if so, invalid selection
if (theForm.division.selectedIndex == 0)
{
alert("The first \"Division Location\" option is not a valid selection.");
theForm.division.focus();
return (false);
} 



if (theForm.Attachment.value == ''){
alert('Please attach a TEXT file in the \"Cases remaining with the Filing User\" area');
theForm.Attachment.focus();
return (false);
}
if((theForm.Attachment.value.toLowerCase().lastIndexOf(".txt")==-1) && (theForm.Attachment.value.toLowerCase().lastIndexOf(".xls")==-1)){
alert("You can only attach a TEXT (.txt) file file in the \"Cases remaining with the Filing User\" area")
return (false);
}      


if (theForm.Attachment2.value == ''){
alert('Please attach a TEXT file in the \"Cases remaining with the Former Firm\" area');
theForm.Attachment2.focus();
return (false);
}
if((theForm.Attachment2.value.toLowerCase().lastIndexOf(".txt")==-1)){
alert("You can only attach a TEXT (.txt) file in the \"Cases remaining with the Former Firm\" area")
return (false);
}  


if (theForm.Attachment3.value == ''){
alert('Please attach a PDF file in the \"Letterhead with Signatures\" area');
theForm.Attachment3.focus();
return (false);
}
if((theForm.Attachment3.value.toLowerCase().lastIndexOf(".pdf")==-1)){
alert("You can only attach a PDF (.pdf) file in the \"Letterhead with Signatures\" area")
return (false);
} 



return confirm("All validations have succeeded and the form is ready to be submitted. Click the OK button to finalize or Cancel to abort. Please DO NOT click the \"SUBMIT CHANGE NOTIFICATION\" button again as attached files take several seconds to upload. Errors may occur with your submission if the button is clicked again. Thank you.");

//var returnValue =confirm("All validations have succeeded and the form is ready to be submitted. Click the OK button to finalize or Cancel to abort.");
//if (returnValue)
//{
//user click ok so return true, here you can keep please wait div as show, two reason, one it has highest z index so it will not allow user to again click on submit button, two it still display processing image, here at this time you can also display different image like uploading file or something like that using javascript
//return true;
//}
//else
//{ //user click cancel so display the form
//document.getElementById('pleasewait').style.visibility="hidden";
//return false;
//}
//}


//alertsay = "ALL VALIDATIONS HAVE SUCCEEDED AND YOUR FORM IS READY TO BE SUBMITTED. CLICK THE OK BUTTON TO COMPLETE THE SUBMISSION PROCESS OR THE X BUTTON TO CANCEL."
//alert(alertsay);
//return (true);
// replace the above with return(true); if you have a valid form to submit to
}
