I have the following code:
<input class="submit-form-on-change type="month" name="@Model.DatePickerFormKey" value="@Model.InitialValue?.ToString("yyyy-MM")">
<script>
document.addEventListener('DOMContentLoaded', function () {
document.getElementById('user-filter-content').querySelectorAll('.submit-form-on-change').forEach(function (element) {
element.addEventListener('change', function () {
this.form.submit();
});
});
}, false);
</script>
I am able to pick a date via date picker but I would like to be able to also fill the input field using the keyboard.
Now my problem here is that every keystroke triggers the form submit.
Is there any way to check if the value of the input is a full valid date?
So I mean that something like 0202-10
is not possible but 2024-10
or even 1993-10
is.