I am developing a django app.
I have date input in my form:
<input type="date" name="date_of_birth" max="03.11.2020" max-length="8" pattern="[0-3][0-9].[01][0-9].[0-9]{4}" class="dateinput form-control" required id="id_date_of_birth">
It allows to enter the date with the year having 6 digits, but I wish it was only possible to enter 4. I also tried to write a simple script:
$(function() {
$('#id_date_of_birth').change(function() {
var date = $(this).val();
console.log(date, 'change')
});
});
but it only starts when I change the year.
I would like the numbers to loop on 4 digits instead of 6.
Can someone give me a hint how to limit the year to only 4 digits?