2

Some HTML <input> tags will allow for min and max values like the numeric input type. I was wondering if there's also such an attribute for the datetime-local input type where it can be set to a min value of the current 'today' date?

Is it possible in HTML to set a selection limit for datetime-local input to only let the user be able to only select dates ranging from 'today' to future dates while preventing the user from selecting past dates.

<form>
  <input type="datetime-local">  
</form>
5120bee
  • 689
  • 1
  • 14
  • 36
  • Per the HTML spec, you can set `min` and `max` on ``, though I’m not sure which browsers support it. And I think it only affects what the date picker shows and doesn’t prevent users from directly entering any date they want. Also, see http://stackoverflow.com/questions/17182544/disable-certain-dates-from-html5-datepicker/20782479#20782479 for a hint at how you can more easily set the date constraints on the server side (the example is in PHP but you can use the same mechanism in other server-side languages). – sideshowbarker Nov 28 '16 at 08:16
  • I have the same issue, there are methods to get only the future dates but no way to get future values for `` – chanaka wickramasinghe Mar 26 '21 at 06:55

0 Answers0