Automate

 View Only
  • 1.  DatePicker - force to show no past dates

    Posted 22 days ago

    Is there a method to force individual patepickers to show no past dates to be selected?

    The following will default any past selected date to current the current date, but I would prefer if they don't even show.

    As a field rule as a custom: 

    $j(function () {$j("#dp_frm_component_input1_2945").datepicker("option", "minDate", 0);});

    Thanks,

    Kurt



    ------------------------------
    Kurt Marshman
    Old World Industries, LLC
    ------------------------------


  • 2.  RE: DatePicker - force to show no past dates

    Employee
    Posted 18 days ago
      |   view attached

    Hi Kurt.

    This is what i love about Javascript capabilities with Automate Evolve. You can surely achieve this, please refer below attached video for steps.

    NOTE: below video contains both scenarios where you want to disable dates on a single datepicker(0mins to 2:26) or all datepickers (2:26 to 3:24).
    -----------------
    Code used:

    • For Single DatePicker:
    jQuery(function ($) {
      const $el = $("#Date-picker-id");
     
      if ($el.hasClass("hasDatepicker")) {
        $el.datepicker("option", {
          minDate: 0,
          showOn: "focus" // removes the button, only opens on click/focus
        });
      }
    });
    -------------------------
    for all datepickers:
    jQuery(function ($) {
      $(".form-datepicker.hasDatepicker").each(function () {
        $(this).datepicker("option", {
          minDate: 0,
          showOn: "focus"
        });
      });
    });
    ------------------

    Hope this helps.



    ------------------------------
    Hammad Naeem
    *Precisely Software Inc.
    ------------------------------



  • 3.  RE: DatePicker - force to show no past dates

    Posted 18 days ago

    Excellent video! Thanks for creating Hammad.

    Kurt



    ------------------------------
    Kurt Marshman
    Old World Industries, LLC
    ------------------------------



  • 4.  RE: DatePicker - force to show no past dates

    Posted 16 days ago

    Hammad,

    I ran into a couple issues:

    When I place your suggested code in the date field the past dates are not greyed out when the calendar pops up. However, when I select a past date in the calendar the date returned to the field is the current date. I found that to be "acceptable".

    What I didn't realize until testing it is the date that was "selected" was the date maintained in a hidden input value in the html. Example - I selected 5/1/2026 and the date field shows 5/5/2026 (which was current date). The html for the inputs value=2026-05-01

    Code Used:

    jQuery(function ($) {
      const $el = $("#dp_frm_component_input1_2945");
      if ($el.hasClass("hasDatepicker")) {
        $el.datepicker("option", {
          minDate: 0,
          showOn: "focus"
        });
      }
    });

    image

    image

    Thoughts on a fix?

    Thanks,

    Kurt

    Using Version 24



    ------------------------------
    Kurt Marshman
    Old World Industries, LLC
    ------------------------------



  • 5.  RE: DatePicker - force to show no past dates

    Posted 16 days ago

    Hi Kurt,

    Did you enable the rule to run on form load?  That's what I had to do to get this to work.



    ------------------------------
    Andrew Landry
    Leprino Foods Company
    CO
    ------------------------------



  • 6.  RE: DatePicker - force to show no past dates

    Posted 15 days ago

    Andrew,

    I had not but just did and it works...so thank you for the response.

    Did I miss that in the video?

    Thanks,

    Kurt



    ------------------------------
    Kurt Marshman
    Old World Industries, LLC
    ------------------------------



  • 7.  RE: DatePicker - force to show no past dates

    Posted 15 days ago

    Kurt,

    I'm glad it worked. I double checked the video myself because I thought I missed something when I first tried. I thought I'd give it a shot and it worked.



    ------------------------------
    Andrew Landry
    Leprino Foods Company
    CO
    ------------------------------