Need advice - automatically restrict the input to show a date range

Hi everyone,

I need help setting a date range in the native form date field (input type=date). It should automatically show the max date of 21 years from “today”, to restrict access for under 21s.

I came across this post but it doesn’t explain if I can set an automatic max date: Extending Webflow Form (ex. Date Picker)

Can I do it with attributes? Or a simple code snippet?

Thanks for your help :slight_smile:

hi @Magda_Wachowicz basic principle is very simple. Here is JS example

I have created also simple index HTML to make more sense.

As I do not use WF Form at all but I hope that these simple examples will point you right direction.

As I have mentioned in comments the dates outside of min/max
are not selectable but visible so it will be up to you to style these the way you need (eg. opacity: 0.5)

not related but you can read this.

2038 Bug Survival Guide: Lessons From Leap Year Code Issues | Tanium.

good luck

1 Like

Hi @Stan that’s brilliant - thank you!

1 Like