I am asked to create a web page that user inserts the age and get some message. If the user is under 21, send to disney.com. I do not know how to send. That is so far what I did. I am not sure the function is correct or not and the HTML button and textfield are not working if I insert the age and click.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>check is over 21 or not</title>
<script>
function CalAge(birthDateString) {
var today = new Date();
var birthDate = new Date(birthDateString);
var age = today.getFullYear() - birthDate.getFullYear();
var month = today.getMonth() - birthDate.getMonth();
if (month < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
return age;
}
if(CalAge() >= 21) {
alert("You are over 21!");
}
if(CalAge() < 21) {
alert("You are under 21!");
}
</script>
</head>
<body >
<input type="text" name="age" size="30" onClick="Calage()" placeholder="Enter your age" />
<br />
<input type="button" onclick="CalAge()" value="SUBMIT Age">
<input type="reset" onclick="CalAge()" value="Reset age">
</html>