
function ValidateField(objField, blnRequired, blnNum, strFieldName)
{

var blnHold = true;
var strValue = objField.value;
if (blnRequired && strValue.length == 0)
	{
	blnHold = false;
	alert(strFieldName + " was left blank.\nThis field is required for registration");
	objField.focus();
	}
if (blnHold && blnNum == 1 && strValue.length > 0)
	{
//Regular Expression
phoneNum='^[(]{0,1}[0-9]{3}[ ]{0,1}[)+-.]{0,1}[ ]{0,1}[0-9]{3}[ ]{0,1}[+-.]{0,1}[ ]{0,1}[0-9]{4}$';
  myReg=new RegExp(phoneNum);

	if(!myReg.test(strValue))
		{
		blnHold = false;
		alert("Area Code and" + strFieldName + " must be numeric,\n Eg.\n (333) 333 - 3333\n 333+333+3333\n 333.333.3333\n 333-333-3333\n 3333333333");
		objField.focus();
		}
	}
if (blnHold && blnNum == 2 && strValue.length > 0)
	{
//Regular Expression,,, this is the E Mail
emails='^[-a-zA-Z0-9_+.]{1,40}[@]{1}[-a-zA-Z0-9_+]{2,40}[.]{0,1}[-a-zA-Z0-9_+]{0,20}[.]{0,1}[-a-zA-Z0-9_+]{0,20}[.]{1}[a-zA-Z]{2,4}$';
  myReg=new RegExp(emails);

	if(!myReg.test(strValue))
		{
		blnHold = false;
		alert(strFieldName + " must be as\n Ex: john@doe.com");
		objField.focus();
		}
	}
return blnHold;
}


function ValidateForm()
{
var blnHold = true;
blnHold = ValidateField(document.vari.Name, true, 0, "Your Name");
if (blnHold)
	{
	blnHold = ValidateField(document.vari.Email, true, 2, "E-mail");
	}
if (blnHold)
	{
	blnHold = ValidateField(document.vari.Phone, true, 1, "Phone");
	}
return blnHold;
}

