0

I have a date picker on my web app, I only want the user to be able to click on a date between today and over 5 days (so today the date is 2020-06-02, the user should only be able to click on dates between 2020-06-02 and 2020-06-06). I have looked for solutions but the only thing I found was using a min and a max, but those do not work for me. Has anyone an idea how I can achieve this?

This is my code:

<div>
    <form method="post">
        <label for="name">Locatie: </label><br />
        <input type="text" id="naam" asp-for="Locatie" />
        <label for="Datetime">Datum: </label>
        <input value="05-19-2020T12:00" min="05-19-2020T12:00" type="datetime-local" id="DateTime" asp-for="DatumTijd" />
        <input type="submit" value="Submit" />
    </form>
</div>

The min and the value both do not work, but it is what I have tried so thats why I am showing this.

Limbro
  • 13
  • 4

1 Answers1

0

Try using minDate and maxDate:

$( function() {
    $( "#datepicker" ).datepicker({ 
        minDate: 0, 
        maxDate: "+5D" 
    });
});
manix
  • 14,537
  • 11
  • 70
  • 107
  • Here's a similar question which is already solved. https://stackoverflow.com/questions/44585148/how-to-i-set-min-and-max-value-for-input-with-type-datetime-local – Algef Almocera Jun 02 '20 at 15:03