Jump to content

Datepicker on form needs age validation

Recommended Posts

I spent the better part of my weekend trying to find the code needed to require my Date of Birth field, which is a datepicker, to be a date that is age 18 or older. I even went to chatgpt and it printed me out some nice code but alas, it did not work. Is this even possible? I read you can add some javascript in either an html code box or inject it into the header/footer to make this happen.

Might anyone be able to help me on this?
https://www.thehavensrq.org/residential-wait-list

Thank you,
Bruno

Link to comment
  • 6 months later...
On 11/18/2023 at 1:15 PM, thehaven said:

I spent the better part of my weekend trying to find the code needed to require my Date of Birth field, which is a datepicker, to be a date that is age 18 or older. I even went to chatgpt and it printed me out some nice code but alas, it did not work. Is this even possible? I read you can add some javascript in either an html code box or inject it into the header/footer to make this happen.

Might anyone be able to help me on this?
https://www.thehavensrq.org/residential-wait-list

Thank you,
Bruno

Hi Bruno, 

You mean to block the past dates by 18 years ago right?

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

I meant like it would fail authentication unless the date indicated the user was age 18 or older. If I block out dates the user may think the form is malfunctioning. I'd rather them insert their real date of birth and receive a "You must be 18 years of age" message if the date is too recent.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.