Javascript not working
I want the "valid_email" to appear only when the user types in the correct email https://codepen.io/saad-shehzad-the-bashful/pen/JoPwQgN
4 Replies
Change this line:
To this:
By including the brackets you are actually calling the function on load. By removing the brackets you are only passing a reference to it so it will only be called when the input actually gets the event. I am sure that somebody else might be able to explain this in more detail.
By including the brackets you are actually calling the function on load. By removing the brackets you are only passing a reference to it so it will only be called when the input actually gets the event. I am sure that somebody else might be able to explain this in more detail.
That's a pretty accurate description, I'd just clarify that when you call a function (
thisFunction()
) the return value of said function is put in its place. Since thisFunction
has no return value, you're passing in undefined
(the default return value if no value is returned) to the function handler
Also, I hope you're not using this in production, @Code-S ♛, because that is not a great email validator:p
oooooh it was that simple
tysm chris and just