<label class="whitetext">Select Date:</label>
<input type="date" class="form-control" name="pickup_date" required>
I have this input field in my html file. I want to make it such that the user can select a date starting from today only and not past dates.
I think it can be done using min but I dont know how to set min to today's date.
Example-->If today is 27th October 2021, then only date 27th and all future dates are accepted as input or past dates are cancelled out or unselectable or something.
You can use setAttribute to set the min with javascript.
let today = new Date()
let year = today.getFullYear()
let month = today.getMonth() + 1 // the months are indexed starting with 0
let date = today.getDate()
let dateStr = `${year}-${month}-${date}`
let input = document.querySelector('[name=pickup_date]')
input.setAttribute('min', dateStr)