JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="Name">
<button id="Confirm">OK</button>

JavaScript

var valid = false;


$("#Name").focusout(function(){
    
    var that = this;
    
    valid = this.value.length ? true : false;
    
    !valid && window.setTimeout(function() {
        $(that).focus();
    }, 0);        
    
});


$("#Confirm").click(function(e) {
    
    if ( !valid ) { return false; }
    
    e.preventDefault();
    
    alert('AJAX-TIME :)');
    
});