<!-- CONTACT FORM VALIDATION -->
<!-- MESSAGE -->

function ContactForm_Validator(theForm)
{

// required_Article

	if (theForm.required_Article.value == "")
 {
		alert("Please enter TITLE OF ARTICLE.");
		theForm.required_Article.focus();
		return (false);
 }

// required_Message

	if (theForm.required_Message.value == "")
	{
		alert("Please enter your MESSAGE.");
		theForm.required_Message.focus();
		return (false);
	}

// required_Name

	if (theForm.required_Name.value == "")
	{
		alert("Please enter your NAME.");
		theForm.required_Name.focus();
		return (false);
	}

// required_Email

	var emailID=document.ContactForm.required_Email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your E-MAIL ADDRESS.")
		emailID.focus()
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false;
	}

// required_Code 


	if (theForm.required_Code.value == "")
	{
		alert("Please validate by entering the given CODE.");
		theForm.required_Code.focus();
		return (false);
	}

	if (theForm.required_Code.value.length < 8)
	{
		alert("You have incorrectly entered the CODE. Please try again.");
		theForm.required_Code.focus();
		return (false);
	}

	if (theForm.required_Code.value.length > 8)
	{
		alert("You have incorrectly entered the CODE. Please try again.");
		theForm.required_Code.focus();
		return (false);
	}

	var checkOK = "PFL41211";
	var checkStr = theForm.required_Code.value;
	var allValid = true;
	var validGroups = 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("You have incorrectly entered the CODE [ PFL41211 ]. Please try again.");
		theForm.required_Code.focus();
		return (false);
	}

	return (true);
}


<!-- EMAIL FIELD VALIDATION -->

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail Address. Please check your spelling and try again.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address. Please check your spelling and try again.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   alert("Invalid E-mail Address. Please check your spelling and try again.")
		   return false
		}

	 if (str.indexOf(at,(lat+1))!=-1){
		   alert("Invalid E-mail Address. Please check your spelling and try again.")
		   return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("Invalid E-mail Address. Please check your spelling and try again.")
	    return false
		 }

	 if (str.indexOf(dot,(lat+2))==-1){
		   alert("Invalid E-mail Address. Please check your spelling and try again.")
	    return false
	 }
		
	 if (str.indexOf(" ")!=-1){
		   alert("Invalid E-mail Address. Please check your spelling and try again.")
	    return false
	 }

 	return true					
	}


