I'm currently learning JavaScript and I had a few questions as to what was wrong with my code. I'm trying to make a simple age check with the ternary operator and form data. I'm trying to make it so that when the input from the form is under 18, you get the message, and when it is over the button appears. Thanks!
<html>
<head>
<title>test</title>
<script src="app.js" defer></script>
<style>
#continue {
display: none;
}
</style>
</head>
<body>
<form >
<span>please enter your age</span>
<input type="number" id="ageInput"/>
<input type="submit">
</form>
<button id="continue">continue</button>
</body>
</html>
and here is my JS !
var userAge = document.getElementById("ageInput");
const continueButton = document.getElementById("continue");
function verification() {
continueButton.style.display = (userAge.value >= 18) ? "block"
: "none";
}
verification();
console.log(continueButton.style.display);