JSFiddle - React, Tailwind, and code Playground

HTML

<input type="tel" id="codeInput" style="background-color:#FFF">

JavaScript

(
    function()
    {
        var x,y,f,g;
        x=document.getElementById("codeInput");
        g=function()
        {
            x.style.backgroundColor="#FFF";
        };
        f=function()
        {
            if(x.value.length>6)
            {
                x.value=y;
                x.style.backgroundColor="#FAA";
                setTimeout(g,50);
            }
            else
            {
                y=x.value;
            }
        };
        x.onkeyup=f;
        x.onclick=f;
    }
)();