-2

Error type: Cannot read property 'value' of null.

login.php:20 Uncaught TypeError: 
    at validaremail (login.php:20)
    at HTMLInputElement.onchange (login.php:73)
validaremail @ login.php:20
onchange @ login.php:73

https://codepen.io/nelsonrita11/project/editor/ANaQKO

pls help me.

Jeremy Thille
  • 21,780
  • 7
  • 36
  • 54
Nelson
  • 1
  • 1
  • 1
    It would help to see the code that is generating the error – Professor Abronsius Dec 30 '20 at 13:54
  • 1
    Questions on Stack Overflow require to be answerable without visiting any external links. Please [edit] your question to add a [mcve] as text into your question. You can create a [Stack Snippet](https://meta.stackoverflow.com/questions/358992/ive-been-told-to-create-a-runnable-example-with-stack-snippets-how-do-i-do) if you want to make it runnable. – Ivar Dec 30 '20 at 14:02

1 Answers1

-1

Your script runs before the HTML markup is loaded. You are trying to select the id="email" element before it appears in the DOM, so it's null, so email.value is undefined.

Run your script at the end of the <body>, after all the HTML markup.

Jeremy Thille
  • 21,780
  • 7
  • 36
  • 54
  • 1
    If this is the case, then it is [a very common duplicate](https://stackoverflow.com/questions/14028959/why-does-jquery-or-a-dom-method-such-as-getelementbyid-not-find-the-element). No need for yet another answer. – Ivar Dec 30 '20 at 14:05
  • @JeremyThille Don't assume who downvoted you. I _did_ vote to close because the question is lacking the necessary details in the question itself. I'm just saying that if this question is indeed the answer, it adds no value over the already existing duplicate. A downvote ("This answer is not useful") is not that odd in this scenario. – Ivar Dec 30 '20 at 18:03