﻿// JScript File

function homeStepOneFieldValidation()
{
	var firstName = document.getElementById('ctl00_cphMiddle_Wizard1_txtLastName');
	var lastName = document.getElementById('ctl00_cphMiddle_Wizard1_txtLastName');
	var phone = document.getElementById('ctl00_cphMiddle_Wizard1_txtPhone');
	var email = document.getElementById('ctl00_cphMiddle_Wizard1_txtEmail');
	var avgBill = document.getElementById('ctl00_cphMiddle_Wizard1_txtAvgBill')
	var errors = "";
    			
	// Check if first name was entered
	if ((firstName.value == null) || (firstName.value == ""))
	{
	    errors = errors + " - First Name is a required field.\n"
	}
				
	// Check if last name was entered
	if ((lastName.value == null) || (lastName.value == ""))
	{
	    errors = errors + " - Last Name is a required field.\n"
	}
	
	// Check if phone number was entered.
	if ((phone.value == null) || (phone.value == ""))
	{
	    errors = errors + " - Phone Number is a required field.\n"
	}
	else if (phone.value.length < 9)
	{
	    errors = errors + " - Phone Number is invalid. There must be at least ten digits.\n"
	}
				
	// Check if email address was entered, and validate it
	if ((email.value == null) || (email.value == ""))
	{
	    errors = errors + " - Email Address is a required field.\n"
	}
	else if (isEmailValid(email.value) == false)
    {
        errors = errors + " - Email Address is invalid.\n"
    }
	
	// Check if Average Monthly Bill was entered and validate it.
	if ((avgBill.value == null) || (avgBill.value == ""))
	{
	    errors = errors + " - Average Monthly Bill is a required field.\n"
	}
	
	if (avgBill.value == "$0.00")
	{
	    errors = errors + " - Average Monthly Bill is invalid.\n"
	}
	
	if (errors != "")
	{
	    alert('The following error(s) occurred:\n'+errors);
	    return false;
	}
    return true;
}

function homeStepTwoFieldValidation()
{
    var zipCode = document.getElementById('ctl00_cphMiddle_Wizard1_txtZipCode');
    var errors = "";
    
    // Check if zip code was entered, and validate it
    if ((zipCode.value == null) || (zipCode.value == ""))
    {
    	errors = errors + " - Zip Code is a required field.\n"
    }
		
    if (isZipCodeValid(zipCode.value) == false)
    {
    	errors = errors + " - Zip Code is invalid.\n"
    }
	    
	if (errors != "")
	{
	    alert('The following error(s) occurred:\n'+errors);
	    return false;
	}
    return true;
}
