﻿function CountCharactersLeft(textField, counterField, max) {
    var tf = document.getElementById(textField);
    var cf = document.getElementById(counterField);

    var length = ($(tf).val()).length;

    if (length > max) {
        cf.style['color'] = "red";
        cf.innerHTML = '[' + (length - max) + ' characters over the limit of ' + max + ']';
    } else {
        cf.style['color'] = "#446644";
        cf.innerHTML = '[' + (max - length) + ' characters left of ' + max + ']';
    }
}

function MaxLengthCheck(source, arguments) {
    var tf = document.getElementById(source.controltovalidate);
    var length = ($(tf).val()).length;

    if (length > source.maxlength) {
        arguments.IsValid = false;
    } else {
        arguments.IsValid = true;
    }
}

