<!--Guest Sign-in!-->

function guestSignIn(theForm){

	var firstNameList = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
	var lastNameList = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
	var weddingCodeList = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ";
	var invalidNum = "0";
	
	<!------------VALIDATE THE WEDDING CODE FIELD------------>

  if (theForm.wedding_code.value == "") {
    alert("Please enter a value for the Wedding Code field.");
    theForm.wedding_code.focus();
    return false;
    alert("Please enter a value for the wedding code field.");
    theForm.wedding_code.focus();
    return false;
  }

  if (theForm.wedding_code.value.length > 25) {
    alert("Invalid Wedding Code - Wedding Code cannot exceed 25 characters");
    theForm.wedding_code.focus();
    return false;
	}

  for (var i=0;i<25;i++){
        wCode = theForm.wedding_code.value.substring(i,i+1);
              if ((weddingCodeList.indexOf(wCode)== -1))  {   
                   alert("Invalid Wedding Code - Use alphanumeric only !\n");
   		   theForm.wedding_code.focus();                        
		   return false;
              }
  }
}



<!--validate Email-->

function validateEmail(theForm){

	var userNameList = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ";
	var emailList = " ;:,/!#$%^&*()|\?`~<>+";
	var phoneDomesticList = "0123456789-";
	var dateList = "0123456789/";
  
	<!------------VALIDATE THE PHONE FIELD------------>	  
	  
  if (theForm.phone.value == "") {
	alert("Please enter a value in the Phone Number field\n");
	theForm.phone.focus();
	return false;
  }
  
  if (theForm.phone.value != "") {
  if (theForm.phone.value.length != 12) {
    alert("Invalid U.S. Phone Number - U.S. Phone Number must be 12 characters\n" + "U.S. phone number example -> 201-123-1234\n");
    theForm.phone.focus();
    return false;
	}
	}

    for (var i=0;i<12;i++){
        NumberD = theForm.phone.value.substring(i,i+1);
                if ((phoneDomesticList.indexOf(NumberD)== -1))  {   
                alert("Invalid U.S. Phone Number - Use numbers and dashes only !\n" + "U.S. phone number example -> 201-123-1234\n");
    		theForm.phone.focus();
		return false;
       }
  }
  
  //check to find "-" in the U.S. phone number

	var foundDash = 0;
	
	for (i = 0; i < theForm.phone.value.length; i++) {
	if (theForm.phone.value.charAt(i) == "-") {
		foundDash = foundDash + 1;
	}
	}
	
	if (theForm.phone.value != "") {
	if (foundDash != 2) {
		alert("There should be two '-' signs in your U.S. phone number\n" + "U.S. phone number example -> 201-123-1234\n");
		theForm.phone.focus();
		return false;
	}
	}
	
	if (theForm.phone.value != "") {
		for (i = 0; i < theForm.phone.value.length; i++) {
		 if ((i == 3) || (i == 7)) {
		  if (theForm.phone.value.charAt(i) != "-") {
		   alert("Invalid U.S. phone number format\n" + "Example => 201-123-1234");
		   theForm.phone.focus();
		   return false;	
		  }
		 }
		}
	} 

	
	<!------------VALIDATE THE EMAIL FIELD------------>

    if (theForm.email.value == "") {
    alert("Please enter a value for the Email field.");
    theForm.email.focus();
    return false;
  }

  if (theForm.email.value.length > 25) {
    alert("Invalid Email - Email cannot exceed 25 characters");
    theForm.email.focus();
    return false;
	}

  //see if there are any invalid characters in the email

  for (var i = 0; i < emailList.length; i++) {
  	error = emailList.charAt(i);
       	if ((theForm.email.value.indexOf(error,0) != -1)) {
                	alert("There is an invalid character in your e-mail address.");
                        theForm.email.focus();
			return false;
                }
  }

  //check to find @ sign and verify that there is only one @ sign in the address

  atLoc = theForm.email.value.indexOf("@",1);
  if (atLoc == -1) {
	alert("There is no @domain name.");
	theForm.email.focus();
	return false;
  }

  if (theForm.email.value.indexOf("@",atLoc+1) != -1) {
	alert("There should only be one @ sign in your address.");
	theForm.email.focus(); 	
	return false;
 	}

  //verify that the domain specified is valid

	if((theForm.email.value.indexOf(".edu")<5)&&(theForm.email.value.indexOf(".mil")<5)&&(theForm.email.value.indexOf(".gov")<5)&&(theForm.email.value.indexOf(".com")<5)&&(theForm.email.value.indexOf(".net")<5)&&(theForm.email.value.indexOf(".org")<5)&&(theForm.email.value.indexOf(".md")<5)&&(theForm.email.value.indexOf(".fm")<5)&&(theForm.email.value.indexOf(".co.uk")<5)&&(theForm.email.value.indexOf(".org.uk")<5)&&(theForm.email.value.indexOf(".com.ro")<5)&&(theForm.email.value.indexOf(".ro")<5)&&(theForm.email.value.indexOf(".cx")<5)&&(theForm.email.value.indexOf(".co.il")<5)&&(theForm.email.value.indexOf(".org.il")<5)&&(theForm.email.value.indexOf(".sh")<5)&&(theForm.email.value.indexOf(".gs")<5)&&(theForm.email.value.indexOf(".ms")<5)&&(theForm.email.value.indexOf(".co.nz")<5)&&(theForm.email.value.indexOf(".net.nz")<5)&&(theForm.email.value.indexOf(".org.nz")<5)&&(theForm.email.value.indexOf(".ky")<5)&&(theForm.email.value.indexOf(".vg")<5)&&(theForm.email.value.indexOf(".lt")<5)&&(theForm.email.value.indexOf(".ac")<5)&&(theForm.email.value.indexOf(".to")<5)&&(theForm.email.value.indexOf(".kz")<5)&&(theForm.email.value.indexOf(".tc")<5)&&(theForm.email.value.indexOf(".tf")<5)&&(theForm.email.value.indexOf(".as")<5)&&(theForm.email.value.indexOf(".dk")<5)&&(theForm.email.value.indexOf(".co.za")<5)) {
		alert("An incorrect domain name was specified in the e-mail address.");
		theForm.email.focus();
		return false;
	  }

	<!------------VALIDATE THE WEDDING_DATE FIELD------------>	 
	  
  if (theForm.wedding_date.value == "") {
	alert("Please provide us with your wedding date.\nIf you don't have one, let us know when you would like to have your wedding.");
	theForm.wedding_date.focus();
	return false;
  }
  
  if (theForm.wedding_date.value != "") {
  if (theForm.wedding_date.value.length != 8) {
    alert("Invalid date format\n" + "example -> 01/23/11\n");
    theForm.wedding_date.focus();
    return false;
	}
	}

    for (var i=0;i<25;i++){
        NumberD = theForm.wedding_date.value.substring(i,i+1);
                if ((dateList.indexOf(NumberD)== -1))  {   
                alert("Invalid date format - Use numbers and / only !\n" + "example -> 01/23/11\n");
    		theForm.wedding_date.focus();
		return false;
       }
  }

  //check to find "-" in the U.S. phone number

	var foundDash = 0;
	
	for (i = 0; i < theForm.wedding_date.value.length; i++) {
	if (theForm.wedding_date.value.charAt(i) == "/") {
		foundDash = foundDash + 1;
	}
	}
	
	if (theForm.wedding_date.value != "") {
	if (foundDash != 2) {
		alert("There should be two '/' signs in your date\n" + "example -> 01/23/11\n");
		theForm.wedding_date.focus();
		return false;
	}
	}
	
	if (theForm.wedding_date.value != "") {
		for (i = 0; i < theForm.wedding_date.value.length; i++) {
		 if ((i == 2) || (i == 5)) {
		  if (theForm.wedding_date.value.charAt(i) != "/") {
		   alert("Invalid date format\n" + "example => 01/23/11");
		   theForm.wedding_date.focus();
		   return false;	
		  }
		 }
		}
	} 
	
	  

	return true;
}



function mod(theForm){

	<!------------VALIDATE THE update FIELD------------>

	if (document.theForm.update[0].checked){
		
	}
	else if(document.theForm.update[1].checked) {
		
		}
	else {
		alert("Please select an option.");
		return false;
	}

	return true;
}




function RSVP(theForm){

	<!------------VALIDATE THE FIRST NAME FIELD------------>

	var firstNameList = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
	var lastNameList = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
	var emailList = " ;:,/!#$%^&*()|\?`~<>+";

  if (theForm.first_name.value == "") {
    alert("Please enter a value for the First Name field.");
    theForm.first_name.focus();
    return false;
  }

  if (theForm.first_name.value.length > 25) {
    alert("Invalid First Name - First Name cannot exceed 25 characters");
    theForm.first_name.focus();
    return false;
	}

  for (var i=0;i<25;i++){
        fName = theForm.first_name.value.substring(i,i+1);
              if ((firstNameList.indexOf(fName)== -1))  {   
                   alert("Invalid First name - Use letters only !\n");
   		   theForm.first_name.focus();                        
		   return false;
              }
  }


	<!------------VALIDATE THE LAST NAME FIELD------------>

  if (theForm.last_name.value == "") {
     alert("Please enter a value for the Last Name field.");
     theForm.last_name.focus();
     return false;
  }

  if (theForm.last_name.value.length > 25) {
    alert("Invalid Last Name - Last Name cannot exceed 25 characters");
    theForm.last_name.focus();
    return false;
	}

  for (var i=0;i<25;i++){
     lName = theForm.last_name.value.substring(i,i+1);
     if ((lastNameList.indexOf(lName)== -1))  {   
          alert("Invalid Last Name - Use letters only !\n");
	  theForm.last_name.focus();                        
	  return false;
   		}
	}


	<!------------VALIDATE THE ATTENDING FIELD------------>

	if (document.theForm.attending[0].checked){
		var attending_val = document.theForm.attending[0].value;
		var guest_val;
		for (var i=0; i < document.theForm.guest_num.length; i++){
			if (document.theForm.guest_num[i].checked){
				guest_val = document.theForm.guest_num[i].value;
		  	break;
		  }
		  else{
		  	guest_val = "";
		  }
		}
		if (guest_val == ""){
			alert ("Please choose the number of guest");
			return false;
		}
	}
	else if (document.theForm.attending[1].checked){
		var attending_val = document.theForm.attending[1].value;
	}
	else{
		//var attending_val = "";
		alert ("Are you attending?\nPlease choose yes or no.");
    return false;
	}


	<!------------VALIDATE THE EMAIL FIELD------------>

    if (theForm.email.value == "") {
    alert("Please enter a value for the Email field.");
    theForm.email.focus();
    return false;
  }

  if (theForm.email.value.length > 25) {
    alert("Invalid Email - Email cannot exceed 25 characters");
    theForm.email.focus();
    return false;
	}

  //see if there are any invalid characters in the email

  for (var i = 0; i < emailList.length; i++) {
  	error = emailList.charAt(i);
       	if ((theForm.email.value.indexOf(error,0) != -1)) {
                	alert("There is an invalid character in your e-mail address.");
                        theForm.email.focus();
			return false;
                }
  }

  //check to find @ sign and verify that there is only one @ sign in the address

  atLoc = theForm.email.value.indexOf("@",1);
  if (atLoc == -1) {
	alert("There is no @domain name.");
	theForm.email.focus();
	return false;
  }

  if (theForm.email.value.indexOf("@",atLoc+1) != -1) {
	alert("There should only be one @ sign in your address.");
	theForm.email.focus(); 	
	return false;
 	}

  //verify that the domain specified is valid

	if((theForm.email.value.indexOf(".edu")<5)&&(theForm.email.value.indexOf(".mil")<5)&&(theForm.email.value.indexOf(".gov")<5)&&(theForm.email.value.indexOf(".com")<5)&&(theForm.email.value.indexOf(".net")<5)&&(theForm.email.value.indexOf(".org")<5)&&(theForm.email.value.indexOf(".md")<5)&&(theForm.email.value.indexOf(".fm")<5)&&(theForm.email.value.indexOf(".co.uk")<5)&&(theForm.email.value.indexOf(".org.uk")<5)&&(theForm.email.value.indexOf(".com.ro")<5)&&(theForm.email.value.indexOf(".ro")<5)&&(theForm.email.value.indexOf(".cx")<5)&&(theForm.email.value.indexOf(".co.il")<5)&&(theForm.email.value.indexOf(".org.il")<5)&&(theForm.email.value.indexOf(".sh")<5)&&(theForm.email.value.indexOf(".gs")<5)&&(theForm.email.value.indexOf(".ms")<5)&&(theForm.email.value.indexOf(".co.nz")<5)&&(theForm.email.value.indexOf(".net.nz")<5)&&(theForm.email.value.indexOf(".org.nz")<5)&&(theForm.email.value.indexOf(".ky")<5)&&(theForm.email.value.indexOf(".vg")<5)&&(theForm.email.value.indexOf(".lt")<5)&&(theForm.email.value.indexOf(".ac")<5)&&(theForm.email.value.indexOf(".to")<5)&&(theForm.email.value.indexOf(".kz")<5)&&(theForm.email.value.indexOf(".tc")<5)&&(theForm.email.value.indexOf(".tf")<5)&&(theForm.email.value.indexOf(".as")<5)&&(theForm.email.value.indexOf(".dk")<5)&&(theForm.email.value.indexOf(".co.za")<5)) {
		alert("An incorrect domain name was specified in the e-mail address.");
		theForm.email.focus();
		return false;
	  }

		


	return true;
}
