Two things are broken: you never call e. preventDefault(), so the form will still submit/reload after the alert, and email is an accidental global that won’t exist in strict/module contexts. Grab the input explicitly and stop the submit when invalid: