﻿var IsPhoneEmpty = true;

function ValidatePhone(sender, args) {

    if (IsPhoneEmpty == true)
        return;
        
    var p1 = document.getElementById('ctl01_txtPhone1');
    var p2 = document.getElementById('ctl01_txtPhone2');
    var p3 = document.getElementById('ctl01_txtPhone3');

    if (p1 != null && p2 != null && p3 != null &&
        (p1.value != '' && p2.value != '' && p3.value != '')) {
        if ((isNaN(p1.value) || p1.value.length != 3) ||
            (isNaN(p2.value) || p2.value.length != 3) || 
            (isNaN(p3.value) || p3.value.length != 4)) {
            args.IsValid = false;
            return;
        }
        else {
            args.IsValid = true;
            return;
        }
    }
}
function ValidatePhoneRequired(sender, args) {
    var p1 = document.getElementById('ctl01_txtPhone1');
    var p2 = document.getElementById('ctl01_txtPhone2');
    var p3 = document.getElementById('ctl01_txtPhone3');

    if (p1 != null && p2 != null && p3 != null) {
        if (p1.value == '' || p2.value == '' || p3.value == '') {
            args.IsValid = false;
            IsPhoneEmpty = true;
            return;
        }
        else {
            args.IsValid = true;
            IsPhoneEmpty = false;
            return;
        }
    }
}

function ValidateVerticals(sender, args) {
    
    var chkList = document.getElementById("ctl01_cbWhatVerticals");
    var cBoxes = chkList.getElementsByTagName("input");

    for (var i = 0; i < cBoxes.length; i++) {
        if (cBoxes[i].checked) {
            args.IsValid = true;
            return;
        }
    }
    args.IsValid = false;
    return;
}
