Announcement

Collapse
No announcement yet.

Min Date on Datepicker

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Min Date on Datepicker

    Hi, does anyone know if it is possible to set a minimum (and maximum) date for the datepicker. I know that a minimum date can be set for the date field in question but there is no restriction on the datepicker itself allowing a 'visitor' to select an incorrect date that then throws up an error when the record is saved.

    I would really like to not allow visitors to scroll back to a date that is not valid.

    Thanks in advance for any help or pointers.

  • #2
    Not for the datepicker, but for the field.

    Regards

    Comment


    • #3
      Managed to solve this by adding the following to the javascript onload() function -

      // Set the start date as today
      $("#id_sc_field_startdate").datepicker("option", "minDate", new Date());


      Then on the sc_startdate_onchange() function, just added -

      var startDateString = $("#id_sc_field_startdate").val();
      $("#id_sc_field_enddate").datepicker("option", "minDate", new Date(Date.parse(currentStartDate)));


      This works fine, sets the minimum date for the date picker on the "start date" field as today when the form loads and updates the minimum date for the date picker on the "end date" field whenever the start date is changed.

      Comment


      • #4
        Awesome.

        thanks for sharing.

        Comment


        • #5
          Added it to the faqs on scriptcase.eu. Great tip!
          Albert Drent
          aducom software netherlands
          scriptcase partner, reseller, support and (turn-key) development
          www.scriptcase.eu / www.scriptcase.nl

          Comment

          Working...
          X