JSFiddle - React, Tailwind, and code Playground

HTML

One: <input type="text" id="f1"><br />
Two: <input type="text" id="f2"><br />
Three: <input type="text" id="f3"><br />
Four: <input type="text" id="f4"><br />
<br />
<input type="button" id="mybutt" value="Go" />

CSS

.error{border:1px solid red;background:yellow;}

JavaScript

var chkFld, arrAll = {'One':'f1','Two':'f2','Three':'f3','Four':'f4'};

$('#mybutt').click(function() {
    var errMsg='', badFlds='', firstBad='';
    for(var key in arrAll){
        chkFld = '#'+arrAll[key];
        $(chkFld).removeClass('error');
        if ($(chkFld).val() ==''){
            $(chkFld).addClass('error');
            //alert('Please complete field ' + arrAll[key] );
            errMsg += '*' + key + '\n';
            if (firstBad=='') firstBad=chkFld;
        }
    }
    if (errMsg != '') {
        alert(errMsg);
        $(firstBad).focus();
    }
}); //END mybutt.click