
<!--

// Email Validation. Written by PerlScriptsJavaScripts.com

function check_email(e) {

	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	
	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
		}	
	} 
		
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}

function check_field(f,thename){
	if(f.value.length < 1){
		alert("You entered less than one character in the "+thename+" field.");
		f.focus();
		if(document.all || document.getElementByID){
				// change the color of text field
				f.style.background = "yellow";
		}
		return (-1);
	}
	return 1;
}
		
function check_form(f) { // f is the form (passed using the this keyword)
	
	if(bride != 1){
		if(!check_field(f.bride,'bride name')){return false;}
		if(!check_field(f.groom,'groom name')){return false;}
		if(!check_field(f.weddate,'wedding date')){return false;}
		//if(!check_field(f.weddatefirm,'firm or approximate')){return false;}
		if(!check_field(f.guests,'guests')){return false;}
		if(!check_field(f.phone,'phone')){return false;}
		
	}
	
	// check the first email address ( the exclamation means "not" )
	good = check_email(f.email.value);
	if(!good){
		alert("Invalid email detected.");
		f.email.focus(); 
		// if the browser is Netscape 6 or IE
		if(document.all || document.getElementByID){
			// change the color of text field
			f.email.style.background = "yellow";
		}
	// make sure the form is not submitted
	return false;
	}
	
	// check the second email address
	if(bride==1){
		if(!check_email(f.recipient.value)){
			alert("Invalid email detected.");
			f.recipient.focus(); 
			if(document.all || document.getElementByID){
				f.recipient.style.background = "yellow";
			}
			return false;
		}
	}
	return true;
}



// -->