arozwalak
4/18/2014 - 1:57 PM

JavaScript: input limit character

JavaScript: input limit character

(function( $ ){
    $.fn.strLimit = function(limit){
        this.on('keyup', function(){
            if ($(this).val().length > limit) {
                $(this).val($(this).val().slice(0, limit));
            }
        });
        return this;
    };
})(jQuery);