// 3D PHP File Form-Mailer Check Form JavaScript Document

// This is an open-source form validation script. Form validation is called by the form tag onSubmit="return cf()" when the form is submitted. If everything checks out, the sendform.php gets called. You can use any form validation (e.g. strict or non-strict - this one is non-strict) or no validation at all. I use this non-strict code for my form-mailer with a semi-strict customer number line added. These comments can of course be deleted upon use.

function cf(){
	if(document.mailform.name.value.length==0)
		{	alert('Please enter your full name.');
			document.mailform.name.focus();return false	}
	if(document.mailform.Email.value.length==0)
		{ 	alert('Please enter your email address.');
			document.mailform.Email.focus();return false	}
	if(isEmail(document.mailform.Email.value)==false)
		{	alert('Please enter a valid email address.');
			document.mailform.Email.focus();return false	}
}

function isEmail(str)
	{
		var supported=0;
		if(window.RegExp)
		{	var tempStr="a";
			var tempReg=new RegExp(tempStr);
			if(tempReg.test(tempStr))supported=1	
		}
		if(!supported)
		
			return(str.indexOf(".")>2)&&(str.indexOf("@")>0);
			var r1=new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
			var r2=new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");
			return(!r1.test(str)&&r2.test(str))
		
	}
