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.

Not for the datepicker, but for the field.

Regards

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.

Awesome.

thanks for sharing.

Added it to the faqs on scriptcase.eu. Great tip!

Hi, could you show us how to do this? Haven’t been able to find a solution on this. Please help… Thank you!