if (!("maxLength" in document.createElement("textarea"))) {
    $("textarea[maxlength]").each(function () {
        var $el = $(this).on("keydown keyup focus blur paste cut", function (event) {
            var keyCode = event.which,
                that = this,
                limit = Math.abs(parseInt($el.attr("maxlength"), 10)) || -1;
            if (keyCode === 13 || keyCode >= 33) {
                if (that.value.length >= limit) {
                    that.value = that.value.substr(0, limit - 1);
                    event.preventDefault();
                }
            }
        });
    });
}

if (!("maxLength" in document.createElement("textarea"))) {
    $("textarea[maxlength]").each(function () {
        var $el = $(this).on("keydown keyup focus blur paste cut", function (event) {
            var keyCode = event.which,
                that = this,
                limit = Math.abs(parseInt($el.attr("maxlength"), 10)) || -1;
            if (keyCode === 13 || keyCode >= 33) {
                if (that.value.length > limit) {
                    that.value = that.value.substr(0, limit);
                    event.preventDefault();
                }
            }
        });
    });
}

Fix off-by-one bug at length check
Fix off-by-one bug at length check

It sliced too much and the if didn't have to check for equality.
