Alert always works; you simply never call it, because your conditions in "if" never true, or, very likely, you simply get an exception on the first condition. If you don't handle exceptions, the code terminates silently.
For example, consider what happens if your element
email
is not found. In this case,
document.getElementById
returns null:
Document.getElementById — Web APIs | MDN[
^].
An attempt to dereference null object reference by taking
value
throws an exception. You can find out what exactly happens if you use the JavaScript debugger.
—SA