I would simply like to prevent users from entering or disable the previous dates in input datetime-local , is there a way to do this?
Here is what I have done, unfortunately nothing happens on this code:
<input type="datetime-local" class="form-control col-md-6" name="book" required>
<script>
var today = new Date().toISOString().split('T')[0];
document.getElementsByName('book')[0].setAttribute('min', today);
</script>
try this
var today = new Date().toISOString().slice(0, 16);
document.getElementsByName("book")[0].min = today;
<input type="datetime-local" class="form-control col-md-6" name="book" required>
In Laravel, Try this:
<label>Select date & time:</label><br>
<input type="datetime-local" name="start_time" min="{{today()}}" value="2024-05-01T00:00" max="2026-01-01T00:00"><br>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With