﻿function toggleChecks(chk, frm) {
    if (('object' == typeof chk) && ('object' == typeof frm)) {
        var isChecked = chk.checked;
        var len = frm.length;
        for (var i = 0; i < len; i++) {
            var el = frm.elements[i];
            if ('checkbox' == el.type) {
                el.checked = isChecked;
            }
        }
    }
}

function validatDate(sender, args) {
    var date = new Date(Date.parse(args.Value));
    if (!isNaN(date)) {
        args.IsValid = false;
    }
}

function validDateLtToday(sender, args) {
    var date = new Date(Date.parse(args.Value));
    var today = new Date();
    var strDate = (today.getMonth() + 1) + '/' + today.getDate() + '/' + today.getFullYear();
    today = new Date(Date.parse(strDate));
    if (date >= today) {
        args.IsValid = false;
    }
}

function validatePhone(sender, args) {
    var re = /[^0-9]/ig;
    var phone = args.Value;
    phone = phone.replace(re, "");
    args.IsValid = (10 == phone.length);
}