JSFiddle - React, Tailwind, and code Playground

HTML

<div>
    <div id="content">
        <input type="file" id="file">
    </div>
</div>

JavaScript

(function($){
    $.fn.ValidateFile = function() {
        var obj = $(this),
            container = obj.parent(),
            errors = (function(e){
                return e[1] = {
                    length:0
                };
            })($.data(container[0], 'errors')),
            total = (function(e){
                return e.total;
            })($.data(container[0], 'errors')),
            functions = {
                AddError: function() {
                    console.log(total);
                    total++;
                    errors.length++;
                },
                ChangeCallback: function() {
                    functions.AddError();
                    container.trigger('error');
                }
            };
        
        obj.parent().delegate('input', 'change', functions.ChangeCallback);
    };
    $.fn.InitContainer = function() {
        var obj = $(this),
            functions = {
                ErrCallback: function() {
                    console.log($.data(obj[0], 'errors'));
                }
            };
        
        $.data(obj[0], 'errors', {
            total:0
        });
        
        obj.parent().delegate('#content', 'error', functions.ErrCallback);
    };
})(jQuery);

$("#content").InitContainer();
$("#file").ValidateFile();