﻿// used for applying a maximum character restraint on multi row textboxes
// implmented by providing a TAMaxLength attribute on the text box itself in the
// html markup as well as calling a line much like this in the code behind:
// this.TextBoxComments.Attributes.Add("onkeypress", "return checkMaxLength(event,this);");
function checkMaxLength(e, el) {
    // if the value pressed is going to take us over our count,
    // return an empty string
    switch (e.keyCode) {
        case 37: // left
            return true;
        case 38: // up
            return true;
        case 39: // right
            return true;
        case 40: // down
            return true;
        case 8: // backspace
            return true;
        case 46: // delete
            return true;
        case 27: // escape
            el.value = '';
            return true;
    }
    return (el.value.length < el.getAttribute("TAMaxLength"));
}


