Input Type Date validation 18 years old below

Viewed 11621

I'm having trouble with validation of input type="date". It shouldn't accept 18 years old below. Could you please help me? Thank you.

I google and search the forum I haven't found the answer. I tried to validate it in the next page using PHP but my professor told me I must validate it in the same page. Like onchange it must be validated.

<input type="date" name="bday" id="bday" value="">
4 Answers
<?php 
        $year=(int)date("Y");
        $year-=18;
        $year=(String)$year;
        $year=$year.'-'.date("m").'-'.date("d");
        echo "<input type='date'  id='dob' name='dob' 
max='$year' required>";
        ?>
Related