JSFiddle - React, Tailwind, and code Playground

HTML

<form id='form' action='#' method='post'>
    <input type='text' id='username' value='' />
    <input type='submit' value='Submit' />
</form>

JavaScript

$("#form").on("submit", function () {
    user = $("#username").val().length;
    if (user < 3 || user > 6) {
        $('#username').css('background', 'yellow');
        setTimeout(function () {
            $('#username').css('background', 'white').focus();
        }, 3000);
        return false;
    }
});