I am making a form through laravel in which I want to accept only future dates.I am validating the date via javascript and popping an alert when past date is entered but the problem is that after the alert it is going to form action url (that the form is submitted) even if the past date is entered. I want it to remain to that page itself. Please help.
<html>
<script type="text/javascript">
function func() {
var aa = document.getElementById('in').value;
var bb=new Date();
var y=aa.slice(0,4);
var m=aa.slice(5,7);
var d=aa.slice(8,10);
if((y>=bb.getFullYear() && m>=(bb.getMonth()+1) && d>=bb.getDate())!=1) {
alert('Enter future date');
}
}
</script>
<body>
<form action="/submitted" method="post">
<input id="in" type="date" name="sdate">
<input type="submit" onClick="func()"></form>
</body>
</html>