how to include javascript error message when user input is invalid
<p>When I input the values I am successfully able to give an output for the age, however I need a validation of the inputs that signals an error and pastes to the browser the warning message. I am using the if statement for this but it does not work.</p>

<pre><code> &lt;!DOCTYPE html&gt;
    &lt;html&gt;
        &lt;body&gt;
            &lt;form&gt;
                Birth Year:
                &lt;br&gt;
                &lt;input type="text" name="birthYear"&gt;
                &lt;br&gt;
                Current Year:
                &lt;br&gt;
                &lt;input type="text" name="currentYear"&gt;
            &lt;/form&gt;
            &lt;button onclick="calculateAge()"&gt;Calculate Age&lt;/button&gt;
            &lt;div id="output"&gt;&lt;/div&gt;



&lt;script&gt;
    function calculateAge() {
    var ghF = document.querySelector('[name="birthYear"]').value;
    var xhF = document.querySelector('[name="currentYear"]').value;
    document.getElementById("output").innerHTML = "You are either "+(xhF - ghF)+" or "+(xhF - ghF + 1)

    if (ghF) || (xhF) !== "number" {
        confirm("Invalid, please try again")
    }
    };
    &lt;/script&gt;
</code></pre>