JSFiddle - React, Tailwind, and code Playground

by abbylangner

HTML

<input type="text" id="test"/>
<input type="button" id="checkit" value="check it"/>
<span id="output"></span>

JavaScript

$("#test").autocomplete({
    source: ['abby','nan','caroline','zach']
});
$("#checkit").click(function(){
    var currDate,currHours;
    var currName = $("#test").val();
    var allNames = $("#test").autocomplete('option','source');
    if(allNames.indexOf(currName)>-1){
        $("#output").html("Name Found");
        addHours(currName,currDate,currHours);  
    }else{
        $("#output").html("Name Not Found");
        //var reqAddName = $.ajax(); //TODO finish forming proper request
        reqAddName.done(function(){
            if(/*name came back as valid*/true){
                addHours(currName,currDate,currHours); 
            }else{
                //provide error message to user
            }
        });
    }
});

function addHours(){
    //make the request and handle response for updating hours
    //include providing error message to user if anything came back empty
}