No, in this case the && is correct. If you look at the code, it's checking if various fields are 'present' and assigning the valid variable if they all are.
If you're wanting to keep the code within the HTML document, you'll need to tell the validator not to check the script by making it a CDATA block (that's XML terminology). The two "commented" (//) lines are what's important here.
alert("This is compatible with XHTML");