JSFiddle - React, Tailwind, and code Playground

HTML

<input name="test" type="text" class="date" id="test" />

JavaScript

var hasAttribute = function(el, attr) {
    if ("hasAttribute" in el) {
        return el.attributes[attr] != null;
    }
    else if ("outerHTML" in el) {
        return (el.outerHTML
                   .replace(el.innerHTML, "")
                   .indexOf(" " + attr + "=") > -1);
    }
};

$("input").val('today');
if (hasAttribute($("input")[0], "value")) {
    alert("input has a value");
} else {
    alert("input needs a value");
}
alert($("input").val());