HTML+JS My Form Validator function doing the exact opposite of its purpose?
i have created a simple JS function to validate the first name and the last name fields to make sure both are filled when submitting the form so i set up a test alert that -by my knowledge- should pop up if either first name or last name is empty or both. but the alert is only popping up when there are strings in the fields for some reason
function validateForm() {
let x = document.forms["myForm"]["fname"].value;
let y = document.forms["myForm"]["flname"].value;
if ((x || y) || (X & Y) != 0) {
alert('TEST')
return false;
}
}
and the HTML
<div class="form-group"><button type="button" class="btn btn-success" id="submitForm" onclick="validateForm()"
;>Submit</button></div>