I am trying to do this: if $('#name') is empty() alert ("Enter valid input") I am guessing I do something like this?
if $('#name') == empty() { 
alert("enter valid input");
}
I want to use a function so I can get used to reusing the same function over and over. I realize I could just type it in individually without using the switch function. Articles like this: Check if inputs are empty using jQuery seem to not use the switch or function method.
function empty(e){
    switch (e) {
    case "":
    case 0:
    case "0":
    case null:
    case false:
    case typeof this == "undefined":
        return true
    default: return false 
    }
    }
</script>
 $(document).on('click','#add_btn',function (){
           if $('#name') 
         $.ajax({
                type:'POST',
                url:'add.php',
                //dataType: "json",
                data: {
                    "name": $('#name').val(),
                    "coffee": $('#coffee').val(),
                }, 
                success: function(data){ 
                    alert(data);
                    if (data=='ADD_OK') {
                      location.reload();
                    } else {
                         alert('something wrong');
                    }
                      }
                 })
            });
    </script>
 
     
    