﻿function checkForm()
{
    var frmContactForm = window.document.frmContact;
    var frmContactName = frmContactForm.tbxName.value;
    var frmContactPhone = frmContactForm.tbxPhone.value;
    var frmContactEmail = frmContactForm.tbxEmail.value;
    var frmErrors = "0"
    //alert(frmContactName);
    
    
    if (frmContactName == "")
    {
        alert("Please enter a contact name.");
        frmErrors = "1";
    }
    else
    {
        //alert("Contact Name Entered");
        frmErrors = "0";
    }
    
    if (frmContactPhone == "" && frmContactEmail == "")
    {
        alert("Please enter a Phone # or Email to contact you by.");
        frmErrors = "1";
    }
    else
    {
        //alert("Contact Info Entered");
        frmErrors = "0";
    }
        
    if (frmContactEmail != "")
    {
        var tfld = frmContactEmail;  // value of field with whitespace trimmed off
        var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/  ;
        if (!email.test(tfld)) 
        {
            alert("Please enter a valid Email address.");
            frmErrors = "1";
        }
    }

    if (frmErrors == 1)
    {
        alert(frmErrors);
        return false;
    }

}