(function($) {

    $.fn.maxlength = function(settings) {

        this.keyup(function() {
            var max = parseInt($(this).attr('maxlength'));
            if($(this).val().length > max) {
                $(this).val($(this).val().substr(0, max));
            }
        });

        return this;
    };

})(jQuery);
