Two things are broken here: you never stop the submit, and email is a sketchy global. Right now it’ll alert “invalid” and still submit/reload because you don’t call e. preventDefault(). And email. value only “works” in some browsers because elements with an id sometimes get exposed as globals; in strict/module code it’ll just be a ReferenceError.