JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="test" />

JavaScript

$.fn.blockInput = function (options)
{
    this.filter('input,textarea')
        .keypress(function (e)
        {
            var char = String.fromCharCode(e.which),
                regex = new RegExp(options.regex);

            return char.replaceAll("(\\d{2})(\\d{3})(\\d{3})(\\d{4})(\\d{2})", "$1.$2.$3-$4");
        });

    return this;
};

$('#test').blockInput({ regex: '[0-9|A-Z]'});