I just started learning php and from time to time I need some JS functions. Today is one of those day. I have an HTML form where I ask for the age of my users and I'd like to check if they put a grater or equal date compared to the today date. This is the HTML code:
var borndate = document.getElementById("borndate");
var date = new Date()
function comparedate(){
if (borndate >= date.getFullYear()){
alert("Looks like you are to young!");
return false;
} else {
return true;
}
}
<div class="form">
<form class="login-form" method="POST" action="main.php">
<input type="date" id="borndate" name="borndate" required="required"/>
<input type="submit" value="submit" onclick="comparedate()"/>
</form>
</div>