Script To Hide Previous Days & Current Day in Date Picker Field for Elementor Forms

Written by :

Posted on :

Tags :

Share :


What This JavaScript Code Does:

Limits the date that can be selected in order to prevent users from selecting a previous or current date.


How To Implement:

Add a HTML element and paste in the script below. Find the filed ID by going to the advanced settings of the date field. Copy the field ID and replace the field ID that’s in the code.

Additional Resources:

The PHP Code:

  window.addEventListener('DOMContentLoaded', () => {
    setTimeout(() => {
      const today = new Date();
      today.setDate(today.getDate() + 1);

      flatpickr("#form-field-field_528cb9d", {
        minDate: today
    }, 500); // 500ms. change to 1000 for 1 second

One Response

  1. HI

    This is exactly the code I am looking for. Unfortunately, i cannot get it to work? I have Hello Theme installed on my site which I believe has the flatpickr base in the code as standard, so no need to install. I placed the code in an HTML tag above the form. This didn’t work. I have also added the code as a code snippet in Elementor and tried placing it in the head, start of body & end of body tags but still no joy. I have doubvle checked that I have the ID right so all in all it should be working just fine. Any suggestions?

Leave a Reply

Your email address will not be published. Required fields are marked *