﻿function validateDonate() {
    var fields = "";
    var focus = "";
    
    if (document.getElementById("txtCardholderName").value == "") {
        fields += "Cardholder Name\n";
        if (focus == "") {
            focus = "txtCardholderName";
        }
    }
    
    if (document.getElementById("txtCCNum").value == "") {
        fields += "Credit Card Number\n";
        if (focus == "") {
            focus = "txtCCNum";
        }
    }
    
    if (document.getElementById("txtAddress1").value == "") {
        fields += "Address Line 1\n";
        if (focus == "") {
            focus = "txtAddress1";
        }
    }
    
    if (document.getElementById("txtCity").value == "") {
        fields += "City\n";
        if (focus == "") {
            focus = "txtCity";
        }
    }
    
    if (document.getElementById("selState")[document.getElementById("selState").selectedIndex].value == "") {
        fields += "State\n";
        if (focus == "") {
            focus = "selState";
        }
    }
    
    if (document.getElementById("txtZip").value == "") {
        fields += "Zip Code\n";
        if (focus == "") {
            focus = "txtZip";
        }
    }
    
    if (document.getElementById("txtCardholderEmail").value == "") {
        fields += "Email Address\n";
        if (focus == "") {
            focus = "txtCardholderEmail";
        }
    }
    
    if (document.getElementById("txtPhone").value == "") {
        fields += "Phone\n";
        if (focus == "") {
            focus = "txtPhone";
        }
    }
    
    if (document.getElementById("txtStudent").value == "") {
        fields += "Student Name\n";
        if (focus == "") {
            focus = "txtStudent";
        }
    }
    
    if (document.getElementById("txtAmount").value == "") {
        fields += "Amount\n";
        if (focus == "") {
            focus = "txtAmount";
        }
    }
    
    if (focus != "") {
        document.getElementById(focus).focus();
    }
    
    if (fields != "") {
        alert("Please complete the following fields:\n\n" + fields);
        return false;
    }
}