Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use the "min" and "max" attributes to limit the selection of future dates in the HTML5 date input.

The "min" attribute sets the minimum date that can be selected while the "max" attribute sets the maximum date that can be selected.

You can set the "min" attribute to today's date to prevent users from selecting a date in the past. For example:

<input type="date" min="<?php echo date('Y-m-d'); ?>">

You can also set the "max" attribute to a specific date in the future to prevent users from selecting dates beyond that point. For example:

<input type="date" max="2023-12-31">

You can use both attributes together to limit the selection of dates within a specific range. For example:

<input type="date" min="<?php echo date('Y-m-d'); ?>" max="2023-12-31">

Note: The "min" and "max" attributes are not supported in some older browsers.